Contextual filters are applied in AND logic. Is there any way to have two or more contextual filters in OR logic?
Contextual filters in Drupal allow you to add or remove information (content) to the currently displayed view. The filter acts dynamically based on the URL. If the provided argument value is in the URL, the view will contain certain results, if the value is not in the URL, the view will be filtered with other results.
A regular filter could give you all nodes written by a specified user. A contextual filter for a node author would be able to display all nodes written by the currently viewed user, or the same user who wrote the currently viewed node.
The title “contextual filters model” was chosen to convey that teachers' disciplinary views and related assumptions are stable antecedents to course planning, largely independent of context.
In views 7.x-3.5 this may not be possible using the UI.
Assume your module name is my_module
Add the following to your my_module.module file
<?php
function my_moudle_views_api() {
return array(
'api' => 3,
);
}
?>
and
the following to 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');
}
}
?>
Source : http://drupal.org/node/1451218#comment-6136692
Whereas in the earlier version of views, the AND/OR option of the contextual filter would be decided by that of the first group of static filters in the 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With