2

I am trying to display nodes in an EVA, attached to a node type that shares taxonomy. The EVA passes the node ID to the EVA, so I have a contextual filter, but am having trouble figuring out how to filter the EVA nodes by their shared taxonomy values. It seems like I need to create a relationship in some way, but that doesn't work.

How can I filter out the nodes in my EVA that share the same taxonomy terms of the main attached node?

2
+50

Construct your eva field view as follows: view of nodes filtered by your content type.

Relationships:

a. Content: terms (field_YOUR_TERM_FIELD). Require this relationship.

b. Taxonomy term: Content with term. Set the Relationship to relationship 'a'. Require this relationship.

Contextual filters:

a. Content: Nid. Set the relationship to relationship 'b'.

b. Content: Nid. NO relationship. In more tick exclude.

Arguments (in Entity content section):

Select 'Use tokens from the entity the view is attached to'. Then add this as your arguments: [node:nid]/[node:nid]

In OTHER section of views: click on query settings, and select 'Distinct'.

The reason two almost identical contextual filters are used is as follows: the first one ties up the relationships that you brought in, the second one excludes the current node from the result set.

2
  • I tried this way not with a node the eva is attached to but with a field collection. To get the field_YOUR_TERM_FIELD I needed an additional relationship (AA:)Entity Reference: Referencing entity (required). Then I used the relationship Field collection item: field_MY_TERM_FIELD, related to AA. In context filters I replaced Content: NID with Field collection item: Field collection item ID. But both filters only WITH relationship to B. Not without or another relationship is possible. There is completely no output. Is there a solution?
    – deelite
    Jun 17 '15 at 21:44
  • This solution is BANG ON. It worked for me after I was about to bang my head on the wall. +1 for J. Reynolds.
    – asiby
    Oct 13 '15 at 2:15
4

From the EVA project page:

In addition, the unique ID of the entity the view is attached to -- as well as any tokens generated from that entity -- can be passed in as arguments to the view.

Pass the Taxonomy terms as arguments to the view attachment. You may then add a contextual filter to the view attachment which can make use of these arguments and require the arguments be of terms within the appropriate vocabulary.

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.