views_query_alter change to operator OR for contextual filters and normal filters
Solutions
Download and install the module Views arguments in filters. It is a sandbox module so you will have to use git.
In your view, remove your contextual filter and replace it with a global null contextual filter.
Then add the filter that you want as the contextual filter to the normal filter area in views, and in its value argument set the value as %1 (ie you are ferencing the global null contextual filter).
Now rearrange the filter and-or groups to your liking.
As a simple try to help, did you implement hook_views_query_alter(&$view, &$query)
as following ?
First, call Views API in YOUR_MODULE.module
:
/**
* Implementation of hook_views_api().
*/
function YOUR_MODULE_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'YOUR_MODULE_NAME'),
);
}
Create a file YOUR_MODULE.views.inc
. It seems that with Views, you don't need to put files[] = YOUR_MODULE.views.inc
in your module's .info file, as you usually would.
Then implement hook_views_query_alter() in views.inc
.
function YOUR_MODULE_views_query_alter(&$view, &$query) {
if($view->name == 'VIEW_NAME') {
dpm($query);
//at this point find the right part to alter and adapt following line
$query->where[0]['type'] = 'OR';
}
}
EDIT: If for any reason, you can't override the View with hook_views_query_alter()
, Views Filter Harmonizer might fit your need.
Views Filter Harmonizer solves an operational foible with the Views module regarding filtering. This small module allows you to have a contextual filter argument apply only when there is no corresponding regular (exposed) filter value present.
Last, check also Views arguments in filters sandbox, or test this patch. Both rely on the same logic, setting a "Global: Null" contextual filters and using it in regular filters. Many people report using it to solve the same And/Or contextual filters issue. Good luck !