0

I'm trying to display content in a view and, beneath each entry, show a teaser of other content to which it is linked via Node Reference.

Here is roughly what I'm trying to show in my View:

Classroom A (title with link)
  L Teacher A (teaser)
  L Teacher B (teaser)

Classroom B (title with link)
  L Teacher B (teaser)
  L Teacher C (teaser)
  L Teacher D (teaser)

I've tried using Relationships and Contextual filters, but find them quite confusing and unintuitive.

The best I've managed is showing the same Classroom A link multiple times, one for each Teacher...

2 Answers 2

0
  • create a view filtering by classroom node types
  • add a relationship like "Entity Reference: Referencing entity", it is related to teacher nodes that are referencing the classroom node.
  • after this, add the classroom node fields and using that relationship, add the teachers fields.
  • in the format views settings, you can choose a field to grouping this nodes, so, choose the node reference field.

This view configuration, it will works only if the node reference field is in teacher node.

0

What you need to do is to use the views_field_view module in combination with the entity reference module to build this. Enable both modules.

In your teacher content type create a entity reference field which reference the class that they teach (let call this field_relate_class).

Then you need to create a view of teachers as child view with a contextual filter using field_relate_class. The setting of the contextual filter should be following: When the filter value is NOT available -> Provide default value -> Content ID From URL When the filter value IS available or a default is provided -> Specify validation criteria -> Basic validator.

Then you need to create views of classes. Add the Content id field and add a Global Views field(views_field_view provide Global View). Make sure content id field is on top of Global Views field.

Once the Global Views field is added. Click on this field, the UI will populate setting for you to select the Views you want to display in this field. Select teacher views you created. There is a Contextual Filter Text box on this setting just fill the token of Content ID. Then Click Save. You are done.

Let me know if you find it difficult in this process.

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.