0

I would like to take my standard taxonomy term view and add a "meta" category that would show up in addition to the term selected. The result should be that items in the meta category show up as well as those in the term being viwewed.

I tried adding the meta category as a regular filter or an additional contextual filter, but there's no way to add the "OR" logic needed between the contextual term filter and the specified meta term filter. In spite of using them for many many years, I still don't fully understand the all settings of contextual filters. Perhaps there is a right way to get it to do what I want?

Thanks for any leads or suggestions.

1 Answer 1

1

You can add "or" conditions to filters -- either regular or exposed -- using Views in Drupal 7 or 8 (in Drupal 6 you need to use the Views Or module).

Add the filters you want -- in your example, a "Has taxonomy term" filter for "meta" and a "Has taxonomy term" exposed filter. Then click the arrow next to the "Add" link to expand the options and select "And/Or, Rearrange".

enter image description here

From there you can add a new group and drag both the "Has taxonomy term" filters into that group and set the operator to "or". (You can also set the operator between groups to "or" for more complicated scenarios.)

enter image description here

To add OR clauses to contextual filters, tick the "Allow multiple values" option and use the "+" or "," characters in the URL to indicate an OR or AND of values.

That should get you what you want.

4
  • Thanks for the suggestion! I'm not sure I understand. The second filter for taxonomy term is the one that is contextual, but it is not exposed. I tried your solution just to make sure I wasn't missing anything, but it finds no results.
    – R. Durham
    Jun 22, 2016 at 13:56
  • I take it back... You cannot add OR conditionals to contextual filters in this manner -- you need to use "+" or "," in the URL to indicate multiple values. I've updated the original answer to reflect this. Also, this will not work between exposed filters and contextual filters without something like Views Harmonizer (drupal.org/project/filter_harmonizer) . I'm not sure this is possible using just contextual filters... I haven't tried yet.
    – mikeker
    Jun 23, 2016 at 1:46
  • Thanks for the correction. Unfortunately, the module doesn't match my use case (it pulls the contextual filter when no regular filter is present, I want it to use both simultaneously) and I don't think we want to add "+meta" to all the category archive URLs. I think I will be putting this task aside for a while unless I get any more suggestions.
    – R. Durham
    Jun 23, 2016 at 17:24
  • By the way, thank you, Mike! This is Ruby from DrupalCon!
    – R. Durham
    Jun 23, 2016 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.