0

I have two content types: Artist and Artwork. An Artwork has a field called field_artist which relates to the relevant Artist node. I want to add a view to the Artist node page, so that all artworks of that artist are displayed.

I tried using EVA, but I can't figure out what relationship and contextual filters to choose. I looked for tutorials but I find this very confusing.

Is there a way to do this with EVA OR in some other easy way? The only crucial thing is that the entity reference field from Artwork to Artist must be used to filter the artworks in the view.

Thanks!

2
  • 1
    I guess the key is to look for reverse entity reference.
    – leymannx
    Oct 14, 2020 at 19:59
  • Thank you @leymannx, searching this term helped!
    – Wouter C
    Oct 15, 2020 at 9:31

2 Answers 2

2

You can build it in Views without EVA.

Here's a great article about different cases of how to build Relational lists in Views (I'm not affiliated): Relationships and Contextual Filters in Views 3 for Drupal

In your particular case you need to look at the 'Pulling fields of “Child” nodes by node reference' section.

You build a list of Artwork, then add the Contextual filter for the Artist ER field, configure it to default to "Content ID from URL", add the Validation that limits it only to the Artist type so it appears only on Artist nodes, adjust the other settings to your particular needs.

1
  • Thank you! The linked article explains it perfectly.
    – Wouter C
    Oct 15, 2020 at 9:31
2

The article mentioned in the accepted answer explains how to do it.

To include this in the view, there are some options.

  1. Using Block layout, place the block in the desired region and filter the block to only display on the content type you desire (Artist).
  2. If you have a custom Twig template, use module Twig Tweaks to leverage it's drupal_view('view_id', 'block_id') method.
  3. Use module EVA to add the view to the node page. The order of display can be managed in "Manage field display" (in this case on the Artist node)

In short:

  1. Create a view for the child node (Artwork) or use an existing one and create a new block (option 1 or 2 above) or new EVA (option 3 above).
  2. Open Advanced > Relationships > Add
  3. Choose Content referenced from field_parent - Appears in: child (field_artist, appears in Artwork)
  4. Choose Require this relationship
  5. Apply
  6. Open Advanced > Contextual filters > Add
  7. Choose ID - Content
  8. Choose relationship field_parent: Content (field_artist: Content)
  9. Choose Provide a default value and select Content ID from URL
  10. Apply
  11. Save the display and add it to your node using one of the methods described above.

Good luck!

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.