0

I have a view using taxonomy CONTEXTUAL FILTERS.

  1. taxonomy vocab 1 terms AND
  2. taxonomy vocab 2 terms

Both are set to get the taxonomy id from the url, limited to a specific taxonomy vocabulary and share any of the terms.

But on taxonomy vocab 2, I would like to have an additional filter to pull content without any vocab 2 terms at all.

something along the lines of

  1. has taxonomy vocab 1 terms AND
  2. has taxonomy vocab 2 terms OR
  3. has NO taxonomy vocab 2 terms

I can do this with two separate views:

VIEW 1

  1. has taxonomy vocab 1 terms AND
  2. has taxonomy vocab 2 terms

VIEW 2

  1. has taxonomy vocab 1 terms AND
  2. has NO taxonomy vocab 2 terms

but I would like to combine the results.

Edit: if I have this set of content with terms, and the Contextual argument is term 1 I want the first and third to be shown in Views results:

content 1 | term 1
content 2 | term 2
content 3 | no term selected

  • I may be missing something here but you seem to be contradicting yourself. If you have the filter to both include and exclude by some criteria then you don't need that filter at all. Can you add examples of your desired results output to clarify what you want? – prkos Mar 26 at 14:33
  • Hi, the vocab 2 has several terms, but they are not required. So can have content as follows: content 1: vocab 2: term 1; content 2: vocab 2: term 2; content 3: vocab 2: no term selected: If the contextual filter has 'term 1', I want to pick up both content 1 and content 3. Content without a vocab 2 term should apply to all. – ice70 Mar 27 at 8:06
0

You can draw some clues from this question: Views contextual filters for NULL value You should use Computed field or some other way of introducing custom PHP into your Views (custom module is the best option).

If you use more than one Contextual and need to have the OR operator between them you can use the Views Contextual Filters OR module.

There is also a patch for the D7 version you can expand on: Add an "OR IS NULL" option to contextual filters.

But since you're using two vocabularies and need to maintain the AND between the two contextuals you won't be able to use the "OR" module and you'll have to come up with a custom code solution for the second contextual that takes care of the both "there is specific term" and "there are no terms" in one contextual filter, so you can combine it with the contextual for the Vocabulary 1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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