2

I'm using Drupal 7:

I have a taxonomy term view that uses two contextual filters (i.e. taxonomy/term/%/%). Under 'Relationships' I have selected: 'Content: Taxonomy terms on node'. Under this relationship I have selected two vocabularies. Under 'Contextual Filters' I have selected: '(terms) Taxonomy term: Term ID'. Within the contextual filter I've selected 'Display contents of "No results found"' under 'WHEN THE FILTER VALUE IS NOT IN THE URL'.

The reason for two contextual filters is because the content is tagged with two term reference fields each of which correspond to a different taxonomy vocabulary.

The problem is that the results I get are not filtered by the second taxonomy term.

For example, if some content has been tagged with 'board of directors' (tid = 29) and 'people' (tid = 34) then everything that is tagged with 'board of directors' displays under taxonomy/term/29/34 even if they have not been tagged with 'people'.

How can I configure my view so the results are filtered according to two taxonomy terms?

1 Answer 1

1

I'm not sure why are you using Relationships for this. Simply, from "Contextual Filters" section, create a "Content: Has taxonomy term ID". In that filter's settings -> "More" settings -> Check "Allow multiple values" which:

If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND).

i.e. go to view_path/29,34 will filter results by both terms.

Hope this helps.

2
  • Yes you are right. I had actually come up with a solution that involved using the Multi-Term Views module. However, I turned this module off and followed your directions and it worked without using the module. I think the problem might have been previously that I was using a custom taxonomy/term view rather than the default taxonomy/term view that Views gives you by default. I couldn't see what the difference was between my view and the default one. I've noticed other things don't work also unless you use the default view. What is it doing that I'm not? Apr 6, 2012 at 10:14
  • The other problem I've now got is one of my vocabularies has child taxonomy terms. In my view if you visit one of these child terms (i.e. taxonomy/term/29) then you get the nodes tagged with that term. However, if you visit the parent term (i.e. taxonomy/term/27) then you get no results even though content has been tagged with child terms of this parent term. I can get the taxonomy/term/27 to work if I use the 'Taxonomy Term (with depth)' context filter but using this means my taxonomy/term/29,34 stops working properly (i.e. it picks up everything tagged with tid 34). Any ideas on this one? Apr 6, 2012 at 10:20

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.