I have been able to separate Views filters into groups and apply an OR condition, following this article: http://www.webomelette.com/drupal-views-filters-and-or-logic
I also understand how to use the hook_views_query_alter() to make a few contextual filters act with an OR statement between each contextual filter.
What I can't figure out is this: how do I make the conditional between the REGULAR filters and the CONTEXTUAL filters? After altering the query, this is what I've able to create:
WHERE
(
( (og_membership_node.gid = '8' )
AND (node.status = '1')
AND (node.type IN ('event'))
AND (field_data_field_event_type.field_event_type_tid = '12')
)
AND(
( (node.status = '1')
AND (node.type IN ('event'))
AND (field_data_field_event_type2.field_event_type_tid IN ('11', '10')) )
)
)
and I want it to be:
WHERE
(
( (og_membership_node.gid = '8' )
AND (node.status = '1')
AND (node.type IN ('event'))
AND (field_data_field_event_type.field_event_type_tid = '12')
)
OR(
( (node.status = '1')
AND (node.type IN ('event'))
AND (field_data_field_event_type2.field_event_type_tid IN ('11', '10')) )
)
)
To give some background of what I am trying to do: I am using Organic groups, and I want my view to show events, Global, Regional and Chapter events. However, if the event is of type Chapter, I want to only show Chapter events which are in the same group as the page content.
I had manually edited the query to move the regular filters associated with the Chapter filter into the contextual filter group, with this:
foreach($query->where[1]['conditions'] as $condition) {
$query->where[0]['conditions'][] = $condition;
}
unset($query->where[1]);