There are two types of content (as an example):

  1. fruits
  2. vegetables

They share the same vocabulary and similar terms. Catalog structure:

---for children
---for men
---for women
---for children
---for men
---for women

Url path for mango: /fruits/mango

I want to show similar vegetable juices for children in the fruit node, if the path matches the difference only with the first part of the url.

Need to show similar content if url path matches /%/juices/for-children

I found this solution (Create view with path relative to taxonomy term), but it doesn’t help me, because the paths change there at the end.

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Nov 5, 2021 at 9:39
  • The linked URL is the correct approach. Use Path component to control which part of the path is the argument. /fruits (path component 1)/juices (path component 2)/for-children (path-component 3) Commented Nov 5, 2021 at 9:43
  • The problem is that this is not the path of the term itself. Node has a path: /fruits/mango. I need a contextual filter by url term path. Or am I misunderstanding...
    – kazah
    Commented Nov 5, 2021 at 10:03
  • Are you adding this as a block in Views? You can use contextual filters on blocks, and you can set the block to display on whatever pages you want at /admin/structure/blocks/. Commented Nov 5, 2021 at 10:16
  • You might want to clarify the structure of both nodes and terms (like put in detail their fields, their relationships). Because currently, I can't tell what is what (what is "juices"? Is it a taxonomy? "for children"? Is that a term? or a boolean on another term?). I also would not be too fixated on "filter by path", as there might be other ways to do this that don't involve paths.
    – Joseph
    Commented Nov 5, 2021 at 12:48

1 Answer 1


The only way I was able to solve this problem was by installing the module https://www.drupal.org/project/term_reference_tree

And then I manually match the related terms together. Like in previous versions in drupal (6,7)

Then created a view.


  • taxonomy term (with limit by vocabulary)
  • field_related_terms (the field you have created with Taxonomy Term Reference Tree Widget)

Contextual Filter: taxonomy term: field_related_terms (with relationship)

When the filter value is NOT in the URL

  • Provide default value
  • Term id from URL
  • Load default filter for related taxonomy blocks
  • Filter by items that contain any of the terms

In section more: Allow multiple values

This is how it works. But how to achieve this only in a view without a module and without manual matching of related terms, I did not understand.

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