Drupal 7 View 上下文过滤器或逻辑

标签 drupal view

上下文过滤器应用于 AND 逻辑。有没有办法在 OR 逻辑中拥有两个或多个上下文过滤器?

最佳答案

在 View 7.x-3.5 中,使用 UI 可能无法实现此操作。

假设您的模块名称是 my_module

将以下内容添加到您的 my_module.module 文件

<?php
function my_moudle_views_api() {
  return array(
    'api' => 3,
  );
}
?>

以下内容到 my_module.views.inc

<?php
function eb_mine_views_query_alter(&$view, &$query) {
  if ($view->name == 'statuser') {
    dsm($query, 'before');
    $query->where[0]['type'] = 'OR';
    dsm($query, 'after');
  }
}
?>

来源:http://drupal.org/node/1451218#comment-6136692

而在早期版本的 View 中,上下文过滤器的 AND/OR 选项将由 View 中第一组静态过滤器的选项决定。

Grouping of contextual filters
Even though contextual filters do not appear in the "and/or" user interface for sorting and grouping regular filters, contextual filters are always added to the first group of filters. Thus the order of the groups can cause the contextual filter to have entirely different effects on the results of a view that has contextual filters. Even though differences might not be apparent through the user interface.

Multiple contextual filters are therefore always in the same "and/or" group of filters, and can not be placed in different groups. There is an effort to add this feature.

关于Drupal 7 View 上下文过滤器或逻辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13531828/

相关文章:

javascript - Jquery UI slider 事件不起作用 Drupal 7

.htaccess - 在 Drupal 中,如何使用 .htaccess 从 ?q= 重定向到干净的 URL?

drupal - 如何在 Drupal 中拥有三栏主页

laravel - 在 Laravel 中重定向以查看但更改 URL

templates - Odoo - 在日历 View 中使用模板?

c - 为每个 mpi 进程使用不同的 View 写入文件

drupal - 如何让菜单面包屑出现在 Drupal 7 的导航栏中?

image - 从 DRUPAL 7 上的图像中删除宽度和高度属性

Django : when client request http methods that are not defined in the view class

mysql - 从多个数据库引擎创建 SQL 服务器 View ?