0

I have 3 content types: "Files", "Actions" and "Templates".

  • In each "Files" node there's a entity reference to an "Actions" node
  • In each "Templates" node there' a entity reference to an "Actions" node

How can I setup a view that shows a list of links to "Templates" nodes on a "Files" node page, based on the entity reference to an "Actions" node for this specific "Files" node?

Edit - I couldnt get Felix' answer to work, so here's a more detailed description of my case:

I have a node called "BAG001", this node has content type "Files.
I have a node called "Procedure A1", this node has content type "Actions"
I have a node called "Form A1", this node has content type "Templates"

In "BAG001" I make an entity reference to "Procedure A1" (field name is "field_action")
In "Form A1" I make an entity reference to "Procedure A1" (field name is "field_related_action")

On the "BAG001" page there's should be a views generated block, showing all templates related to "Procedure A1". In this case that would be "Form A1".

I tried setting up a view using the following settings:

  • 1) Relationship -> Entity reference: field_action
  • 2) Relationship -> (Content entity referenced from field_action) Entity Reference: Referencing Entity [with a relationship to (1)]
  • 3) Contextual filter -> Content: NID [with a relationship to (2)]

2 Answers 2

1
  1. Create a view that shows a list of templates.

  2. Add a relationship to the actions content type (Entity Reference: Referenced Entity via field_related_action).

  3. Add a relationship to the files content type (Entity Reference: Referencing entity via field_related_action).

  4. Create a contextual filter based on the current nodes nid. When you create the filter then When the filter value is NOT available select Provide default value and choose content ID from URL. Also this filter should be for the second join to the file node type.

  5. Set that view to show in a block on each files page.

10
  • 1
    Nice, about the same time, the same format, the same number of steps (no longer true after your edit but oh well), totally different approach :D
    – Mołot
    Commented Apr 24, 2014 at 13:41
  • @Mołot ah ha - but I added a step 5! :)
    – Felix Eve
    Commented Apr 24, 2014 at 13:42
  • Hi Felix, thanks for your response. I've been fiddling around with contextual filters and relationships for hours, but can't get it to work :( I've tried the settings you described, but none of the template links show up. in step 2, i take it you mean "Entity reference: actions" and in step 3 "Entity reference: referencing entity -> files". Do i have to set the relationship in step 3 to the relationship added in step 2? And don't have to set a relationship for the contextuel filter? Commented Apr 24, 2014 at 14:18
  • The relationship in step 3 should indeed relate to actions. The contextual filter will use the nid of the file content type, so yes, it will be using a relationship.
    – Felix Eve
    Commented Apr 24, 2014 at 14:25
  • Thanks for your reply felix, I've added the relationships, but still no output. I've edited my question with some more info, any other suggestions? Commented Apr 24, 2014 at 14:57
0
  1. Set reference field in Files content type to display Actions
  2. Set up corresponding entity references between Actions and Templates
  3. Create a display for Actions, that will display only corresponding entity references of Templates.
  4. Use this display in 1.

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.