2

To first explain the set up, I have a custom content type that represents a candidate. I have a relation between candidate and users where the relation has some fields (using the relation module). I want to have a view that displays the fields of relation on the candidate page that has that relation.

So far I have tried Entity Views Attachment but the issue with that is it adds the relation view I have set up to every instance of candidate. I've also been trying view reference but that doesn't seem to be the module I'm after either.

I think I need to add something like an extra filter or something to the EVA view that only will show relations that involve the current candidate node, but I'm not sure if that is possible or not.

0

Instead of creating a view of relations, you should create a view of candidate nodes. Then you can use a contextual filter to limit the results of the view to the candidate node you are currently viewing. The fields of the relation can then be added via a relationship.

Create a view of content of type candidate, for example located at node/%/info; then under the Advanced settings of the view add a contextual filter with Provide a default value: Content ID from URL (i.e. the candidate node id) as the argument. You can use the same setting when the argument is provided by EVA instead of via the URL, with the default configuration of Use the ID of the entity the view is attached to (but the first example is useful to understand where the argument comes from).

Now in order to get the relevant Relation fields displayed, under Advanced add a relationship using Content: Relation: <your relation label> (node → relation).

Under Fields you can now add the desired Relation fields, specifying that it should use the relationship you just added.

Note the difference between relationship (≈ SQL table join) and relation.

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.