上下文过滤器应用于 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/