Changing the logic for an exposed taxonomy select in a view So, I have a view of a content type, and this content type has three unique taxonomy terms it are: Alpha, Beta, and Both.

Currently, my view lists all nodes of this type, and I've added an exposed filter that lets the user select one and only one of the three terms above, like so:

Both -> Show only content tagged Both

Alpha -> Show only content tagged Alpha

Beta -> Show only content tagged Beta

What I would now like to do is extend the behaviour of the filter so that the following happens:

Both -> Show only content tagged Both

Alpha -> Show only content tagged Alpha and Both

Beta -> Show only content tagged Beta and Both

So as you can probably see, if something is Both, then it is also Alpha and Beta. Obviously the taxonomy terms themselves don't contain this semantic information.

I cannot use "All" to represent Both because then selecting Both -> Alpha, Beta, Both.

So I'm thinking that somehow I could make Alpha and Beta a child term of Both, and Better Exposed Filters might allow this logic to work? Or will I need to use a hook - if so, which hook and any ideas about how I might approach it?
You need to use hook_views_query_alter(). And the logic would be as below.,

Both -&gt; Show only content tagged Both
When the user selects the Both, make no changes in the hook, just return the default result. So by this way the contents tagged under Both will be displayed.

Alpha -&gt; Show only content tagged Alpha and Both
Now use the alter hook, by default the query will have alpha's tid in it. Here you need to add the Both's tid to the query. So now the Alpha and the Both will be displayed.

Beta -&gt; Show only content tagged Beta and Both
Now use the alter hook, by default the query will have Beta's tid in it. Here you need to add the Both's tid to the query. So now the Beta and the Both will be displayed.


In simple term, just use the alter query and add the Both's tid to it. So that we will get the Both's content in all cases.