3

I've browsed through (and tested) every solution I could find here to this seemingly simple challenge.

I've got multiple content types (fx. News, Releases, Events, Videos etc.) that are referencing the content type "Artists" using an entity reference-field.

I want to have related content-blocks that shows the related news, releases etc. for the artists references in the node.

I've done this in D7 but it seems the approach have changed a bit since then (?).

What I thought I should do (with content type 'release' as example:

  • Create a related release-block in views
  • The a relationship 'Content using field_artist', require this relationship
  • Add contextual filter, select relationship, select 'content id from URL' as default value

But no results appear when doing this. If I remove the relationship I get 1 result, the node I'm already on...

What am I doing wrong?

  • 1
    Try removing the relationship and just have the contextual filter for 'content artist' with 'content id from URL' as default value. also Specify validation criteria to be content and type to be artist. – danuddara Jul 14 '17 at 3:23
  • 1
    You might have to work around this problem by starting with 'display all results' when there is no argument and then diving in to contextual filters. cannot give a correct answer for this.. sorry mate. just check the results after placing the block into a page. sometimes it is worth to see the results in there rather than the preview in views. – danuddara Jul 16 '17 at 20:54
0

As mentioned in the comments you don't need any Relationships to filter out the related content. Simply add the Contextual filter for your Entity Reference field, and configure it with a Default value to pick up Content ID from URL, and validation criteria to the Artist content.


You can use the Relationship if you need information other than the Artist node ID in your Views, for example, if you have an independent Views Page showing all Releases, and you want your Contextual filter to be in your URL showing the Artist name and not the ID number:

/releases/Beatles

for all Releases nodes referencing the Artist Beatles.

And it's still working the same as it did in Drupal 7, apart from the different wording in the names, you just added the wrong Relationship.

It should not be the 'Content using field_artist', but Content referenced from field_artist.

'Content using' that field are the nodes with the ER (News, Releases, etc.) so you're just pointing back to what you already have in your Views. This is a "backwards" Relationship.

The 'Content referenced from field_artist' Relationship is pointing towards the Artist nodes, and through adding that Relationship you'll have the Artist data available in your (Releases) Views. This is the Relationship you want to you in this case.

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.