1

Using Drupal 8

I have a working setup my problem is when I try to access a taxonomy term that is made up of two words.

Set up.

  • View : shows nodes of content type A
  • Has relationship (required) with a field in the content type that stores the taxonomy term (one or more terms need to be associated to each content type)
  • Has contextual filter (that uses previous relationship) to get the taxonomy term from the URL. The filter gets the default value from Raw value from URL with Path component: 2 , and it has Use path alias instead of internal because the URL has the taxonomy term name. It also has Specify validation criteria by Taxonomy term name by Transform dashes in URL to spaces in term name filter values so that fan-art can be correctly matched to taxonomy term fan art.

I have no problem with taxonomy terms made up of one word, it's the ones made up of two words that are giving me a headache, any ideas?

  • These are two different terms ?? fan and art – Shreya Shetty Nov 7 '16 at 7:21
  • It's just one, it's called "Fan Art", but the url for it is fan-art, it's a single Taxonomy Term. – Chayemor Nov 7 '16 at 11:22
  • Try term id from url option instead – Shreya Shetty Nov 7 '16 at 12:27
  • It works with that just fine, I just wanted to learn why it doesn't work with the other set up. – Chayemor Nov 7 '16 at 12:33
0

I gave up trying to understand why it doesn't work and resorted to using Has Taxonomy term ID instead.

  • The URL contains the taxonomy term ID so only a Contextual Filter is needed. In raw value the URL is taxonomy/term/[id] , so all that needs to be done is tell the Contextual Filter to Provide default value from Type Raw value from URL and Path Component 3. I also added a Specify validation criteria WhenThe Filter Value is available or a default is provided, of Validator Taxonomy term ID and chose the appropriate Vocabulary.
0

I'm not sure if this meets the requirements of your specific use case, but for anyone else who ends up here looking for something similar here it is: In the contextual filter select 'Name' instead of 'Taxonomy Term ID' and then check the box 'Specify validation criteria' and select 'Taxonomy term name' as your validator. Then check the box 'Transform dashes in URL to spaces in term name filter values' enter image description here

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.