2

I need to keep things in taxonomies so that I can retain the faceting behaviour in search, but I would also like to set up a more conventional way of drilling down through pages (and I'm hoping Views will let me do this). I'm wondering if I can have a Views page that lists all the items in one taxonomy package, but when a user clicks on one of those items, they are taken to another set of taxonomies. When they select something from that page, they are given only the list of nodes that have both taxonomies applied to them.

It will probably be too confusing to explain exactly what I'm working with, so let's say I was creating a page that collects government documents. Every node corresponds to one document, but every document will have a taxonomy for region (i.e., California, Texas, etc.) and department (i.e., Transportation, Education, etc.). So the first View would show all the states, and when they click on a state, they're taken to a list of departments. When they click on a department, they're shown a View that lists all the documents for that state.

I realize this is just faceting behaviour, but I've been requested to build something like this anyway.

2
  • Will the drilldown of vocabularies always be State > Department > Documents? – thumbson Feb 14 '15 at 6:40
  • Yes. The way the people I'm working for conceptualize this is in a directory-type structure, but creating, say, a Department of Transportation for every State is obviously a poor way of handling it. – Jaguar Wong Feb 16 '15 at 16:26
0

One solution is to create a view showing taxonomy terms.

Display 1

Create a page display with a path "documents"

Add a relationship "Taxonomy term: Content using <state vocab>." Require this relationship.

Under Other > Query Settings select Distinct

Add fields

  • Taxonomy term: Term ID
  • Taxonomy term: Name

Exclude term ID from display

Rewrite the results of Name > Rewrite the output of this field: <a href="/documents/[tid]">[name]</a>

Add a filter Content: Type (= <your document content type>)

Display 2

Create a new page display with a path "documents/%"

Remove the Relationship for the state for "This page (override)" and add a relationship for your Department taxonomy. Require this relationship.

Add a contextual filter for Content: <state field> and display contents of "No results found" when filter value is not in the URL.

Edit the rewrite value of your name field, make sure to select "This page (override)": <a href="/documents/!1/[tid]">[name]</a>

Display 3

Create a third page display with a path "documents/%/%"

Keep the state relationship from the view's defaults, but add a relationship using "This page (override)" for your Department taxonomy. Require this relationship.

Add a contextual filter, override for this display, for Content: State and then add one for Content: Department.

Override your fields for this display, removing the Term ID and Term Name, and add a field for Content: Title.

If I have explained this well enough, display 1 should give you a list of states that link to display 2 using the contextual filter to give a list of departments from that state, linking to display 3 showing a list of your document node titles from that state department.

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.