1

In Drupal 8, I have a content type Story, with a multi-value entity reference to content type Project, which, in turn, has a multi-value reference to Team-Member, which has a single-value reference to Person. In my story node, I want to show a list of projects, and within each, a list of team members.

I have an embedded view (content type Story), to which I'm passing the nid as a contextual filter, with 3 relationships defined: referenced Projects, referenced Team-Members, and referenced Persons. I've added fields from all 3 types, each using the correct relationship, I'm pretty sure.

I'm getting Project fields correctly, each Project in a row. But I'm not getting anything for Team-Members or Persons.

Am I asking this view to do something views can't do, by having multi-value references 2 levels deep? Is there a better approach? Am I missing something?

0

Am I asking this view to do something views can't do, by having multi-value references 2 levels deep?

Yes, to my knowledge there is no way to go 2 levels deep for this scenario.

One possible solution, to work around this constraint, would be to use Views Field View and...

1) Create a team member view that uses the project nid as a contextual filter.

2) Add the project nid (content id) as field to your original view so you can pass it to the views field view.

3) In original view, add a views field, select the team member view you created in Step 1 and pass it the project nid (content id).

  • Thank you for validating my conclusion! I considered Views Field View, but the twig solution (see my answer) is working pretty elegantly for this situation. – timwilson Jul 24 '18 at 13:48
0

After spending a day trying to make this work as an embedded view, I decided to take another approach. Given that my need here is specific to a particular page template, I just wrote a nested loop in twig, with a couple of tests to replicate filters the view would have applied. Much simpler for this situation.

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.