3

I need to display nodes in a view, based on a combination of multiple taxonomy terms, in multiple vocabularies. For example, for car sales, one vocabulary lets the visitor select one model, and another selects the color.

My custom path looks like this:

/sales/cars/models/%            // taxonomy view
/sales/cars/colors/%            // taxonomy view

/sales/cars/model/%/color/%     // taxonomy filter

URL:

mydomain.tld/sales/cars/model/land-rover/color/red

I assume I can do this by exposing filters but how?

0

1 Answer 1

8

When you create your views page you set the path to /sales/cars/model/%/color/%

Add contextual filters:

You need to create 2 Contextual Filters, both of them are: Content: Has taxonomy term id so repeat the process below twice.

contextual filter taxonomy term id

On configuration of first contextual filter, you need to set:

"WHEN THE FILTER VALUE IS NOT AVAILABLE" -> Provide default value -> Raw value from URL -> Path component

contextual filter taxonomy term id options raw value from url

Also check "Use path alias" if the URL is an alias rather than a system path.

contextual filter taxonomy term id use path alias

Now you need to validate it, on same configuration overlay screen under

"WHEN THE FILTER VALUE IS AVAILABLE OR A DEFAULT IS PROVIDED"

tick "Specify validation criteria"

contextual filter taxonomy validation criteria

and select "Taxonomy Term" for Validator. Check the appropriate Vocabulary for each contextual filter, and finally set "Filter value type" to "Term name converted to term id" and check the checkbox "Transform dashes in URL to spaces in term name filter values".

contextual filter taxonomy term id custom filter

Set "Action to take if filter value does not validate" to whatever your needs.

5
  • 1
    I added screnshots to your answer, thank you again
    – mate64
    Jun 20, 2013 at 14:09
  • @cept0 and I rejected your edit as you did not fill "image descriptions", making the post above way less searchable = less useful for future visitors. Describe what's on the screenshots.
    – Mołot
    Jun 20, 2013 at 14:12
  • @cept0 dammit, can't undo my vote. Sorry. But I bet it'll be accepted anyway now.
    – Mołot
    Jun 20, 2013 at 14:21
  • your screen shot shows the path component as "3" but the 3rd element in that path is "model". according to your example, what should the appropriate path components be?
    – Rob Orr
    Dec 21, 2015 at 20:00
  • @RobOrr path components start from 0. model is 2.
    – Beebee
    Dec 22, 2015 at 12:51

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.