2

I have a content type that has an entity reference to a taxonomy term. The referenced taxonomy term has furthermore taxonomy terms referenced to it.

On the taxonomy term view page, I would like the content appear, that refers to the terms nested inside first term reference.

The idea of double nested content and display on the taxonomy view page worked for me well, when I used for the first level nesting another content type instead of a taxonomy term. That way I could successfully apply following relationship and contextual filter on the view. I added a relationship to the entity reference field’s content and applied it to the contextual filter.enter image description here

Now, wanting to use a taxonomy term as first level reference, I am not able to get it work. I thought the following should work, but it does not:enter image description here

What relationship do I have to apply, to get the desired result?

(I hope I was able explain my problem comprehensibly)

Edit:

The schema is following:

NODE 1 > TERM 1 > TERM 3

NODE 2 > TERM 2 > TERM 3

TERM PAGE (taxonomy/term/3) SHOW: NODE 1 + 2

  • The nodes have the reference field "field_key_data" that references the vocabulary "architecture". The terms in the vocabulary "architecture" have a term reference field "field_style" (TERM 1 or TERM 2) of another vocabulary.
  • The term in "architecture" may be different, but can reference to the same value in "field_style" (TERM 3).
  • If this is the case, the TERM PAGE for term 3 should show as result NODE 1 and NODE 2.
  • Futhermore the result should be displayed with depth.

2 Answers 2

2

Show only grandchild nodes on Taxonomy term pages

In more words: Add nodes to Taxonomy term pages that are tagged with terms that reference the term shown on that page. This means that nodes that directly reference the TID will not be shown. Instead, we show nodes that have an additional Taxonomy link in between, a sort of grandchild connection.

We first introduce the "parent" connection (in your case it's "Architecture" from field_key_data). Then through it we bring in grandparent "Style" information from field_style. Since we want to show nodes that relate to that TID through that "lineage" we simply use Term ID Contextual filter with the "grandparent" Relationship.

  1. Clone (Duplicate) the default Taxonomy term View (which is of Content type). It already has one Contextual filter (Has Taxonomy Term ID) that is responsible for showing all nodes tagged with that term. Remove it, we don't want parents, we're only interested in grandparent.
  2. Add a Relationship Taxonomy term referenced from field_key_data.
  3. Add another Relationship Taxonomy term referenced from field_style, it will use the first Relationship.
  4. Add a new Contextual Filter Term ID, make it use the second Relationship, and configure it:
    When the filter value is NOT available
    Provide default value
    Taxonomy term ID from URL
    Load default filter from term page
    When the filter value IS available or a default is provided
    Specify validation criteria
    Taxonomy term ID
    Style (or whatever in your case)
  5. Under Query settings choose Distinct because you'll see duplicated results because Relationships introduce many connections so to prevent it Distinct only shows each node once.

No need for Contextual OR BTW, we only have one Contextual filter anyway :)

BTW you can "require" both Relationships since this entire scheme relies on existence of grandchildren.

7
  • Thank you very much once again. With your explanation, I was able to display this grandchild relationship. But the reason I did not manage it by myself before is unfortunately the reason, why my problem is still not resolved: Before, I tried to use the contextual filter “has taxonomy ID (with depth)” (with the same relationship) as I furthermore need to display the results with depth. Is there a chance to display the depth of the grandchildren, too? (I added this to my question as it was only described on the screenshots)
    – Benjamin
    Commented Sep 8, 2018 at 11:18
  • By using the same relationship with the "has taxonomy ID (with depth), I get some strange - for me unexplainable – results: It shows some correct results, but not all and not for the whole depth.
    – Benjamin
    Commented Sep 8, 2018 at 11:19
  • What do you mean "displayed with depth"? The views results are nodes that are tagged with a specific term, it's just that the node is connected through 2 connection instead of a direct one connection. "With depth" can produce unexpected results with Relationships. My answers already introduces hierarchy information through Relationships. "With depth" is a different approach.
    – prkos
    Commented Sep 8, 2018 at 14:29
  • If TERM 3 ist the child of another TERM 4 of the same vocabulary, I would like the NODE 1 and 2 be also listed on the term page of TERM 4. I was able to achieve it by using another content type (NODE 1 > NODE other content type > TERM 3). The actual funcionality: imaginoso.com/t/modernism/brutalism (term modernism is the child of brutalism). But I would prefere to use a taxonomy (for several reasons) instead of another content type for the nesting.
    – Benjamin
    Commented Sep 9, 2018 at 11:00
  • That is exactly what this answers gives steps for. The node that is tagged with term 3 will be displayed on term 4 page if you configure it like in this answer. If you need something different you have to ask a different question and give all the relevant information.
    – prkos
    Commented Sep 9, 2018 at 19:53
0

Add cousin nodes to Taxonomy term pages

In more words: Add nodes to Taxonomy term pages that are tagged with terms that reference the term shown on that page.

Node > Original Term > Referenced term > Other nodes

Node is tagged with some term, that term has a field referencing another term, the other term also has nodes tagged with it. So it's kind of a cousin relationship between nodes.

What is required is a Contextual filter that filters out nodes tagged with a term, OR nodes tagged with a term that references the original term.

To do that we need to use Views Contextual Filters OR module.

  1. Clone the default Taxonomy term View (which is of Content type). It already has one Contextual filter (Has Taxonomy Term ID) that is responsible for showing all nodes tagged with that term. You can leave that active.

    The second Contextual Filter has to display nodes that have been tagged with terms that reference the "original" node. We have to add Relationships to introduce that new information into the Views.

  2. Add a Relationship to Taxonomy terms (term).
  3. Add another Relationship for the Taxonomy field referencing another Taxonomy field, it will use the first Relationship.
  4. Add a new Contextual Filter for that same Field between Terms, make it use the second Relationship, and set it to display all results.
  5. Under Query settings choose Contextual filters OR.

Now if your term 1 is referencing term 2, if you go to taxonomy/term/1/2 it will show all nodes tagged with term 1 AND also all nodes that are tagged with term 2.

2
  • First of all: Thank you so much that you take your precious time trying to understand my problem and help me find a solution. I am not 100% percent sure if I was able to explain my problem properly and if you understood it the right way. I could not resolve my problem with your solution, but I am also not sure if I applied it correctly, this is why I improved my original question. As relationships I took "Taxonomy term referenced from field_key_data" and then "Taxonomy term referenced from field_style". But I did not know what "same Field between Terms" means (I tryed several options).
    – Benjamin
    Commented Sep 2, 2018 at 18:19
  • Thank you for the clarification. Sometimes the structure can be difficult to explain. Your question now seems to be about second cousins, not cousins. I expect it will be a different approach, maybe even easier to solve. I'll add a new answer if I figure it out.
    – prkos
    Commented Sep 2, 2018 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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