Score:0

Similar content with contextual filter by url

in flag

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

  1. fruits
  2. vegetables

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

-Fruits
--juices
---for children
---for men
---for women
-Vegetables
--juices
---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.

cn flag
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)
kazah avatar
in flag
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...
cn flag
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/`.
in flag
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.
kazah avatar
in flag
Sorry for not explaining correctly right away. Vocabulary: catalog `-Fruits --juices ---for children ---for men ---for women -Vegetables --juices ---for children ---for men ---for women` For example, I have fruit mango, that relative to term ("fruits" -> "juices" -> "for children"). I have vegetable carrot that relative to term ("vegetables" -> "juices" -> "for children"). Now I want carrot to show as related content to mango.
kazah avatar
in flag
I add structure to main question for clarification.
Score:0
in flag

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.

Relationship:

  • 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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.