Drupal 7 views - how to combine a contextual filter with a regular filter (with OR)?

1.3k Views Asked by At

Ok, so I have a "playlist" content type, with a node reference field and a boolean field called "always display this playlist".

I have a "playlists" view with a contextual filter based on the node reference. So, when I go to "/playlists/35", it shows all the playlists that reference node 35.

All good so far.

One extra requirement is that the view needs to also display all the playlist that have the "always_display_playlist" field set to 1 (that's the boolean field).

So basically the view needs to display playlists that match the contextual filter OR that have the boolean field set to 1.

So far I have failed rather miserably in making that work. The contextual filter works great, but of course it will only display playlists that have the node reference matching the argument. How can I combine the contextual filter with another regular filter, but with "or"?

Thanks a lot for any clue or idea!

2

There are 2 best solutions below

0
Pierre.Vriens On BEST ANSWER

Option 1

Consider the Views Contextual Filters OR module, which only has a dev version today. Excerpt from its project page:

... provides a views plugin which modify query to support OR conditions for contextual filters.

Option 2

Otherwise the Views EVI (Exposed Value Injector) module, which only has a beta version today. Excerpt from its project page:

This module solves the fundamental and longstanding problem (#357082: Pull filter value from an argument? & Itangalos Sandbox) of views argument filters (=contextual filters): they are far less potent than regular filters.

It does this by allowing to wire argument tokens to exposed filters and optionally hide them. It also allows new use cases, think: use one exposed widget for two filters.

Credits (for Option 2): Hubert

1
kimberly On

If you click on the dropdown beside filters you could potentially use two different filter groups, one that corresponds to the contextual filter and manage it with views filter harmonizer and the other group with the boolean filter and have the OR between them.