1

I have 2 content types: schools and courses.

On the schools content type, I created a field called 'Courses At This School' which is an entity reference field to the courses content type.

So, I edit a school and then I can add which courses the schools runs based on nodes I created on courses.

I now need to create a block view but cannot get my head around how to do this. This block will be placed on the schools node pages and will show which courses the schools run so I'll need a contextual filter too.

I have tried playing around with this but I am getting nowhere. Do I create a view and filter by courses or schools?

  • If your schools directly reference courses in the reference fields, you should be able to see the courses listed on each school node after you save it. You can even show more information using the CT view modes (not the same as the Views module). Or maybe you want school info on course nodes? – prkos Sep 27 '18 at 22:43
1

Please follow the below steps. You will achieve what you have asked.

1. Go to Structures > Views > Add a New View (named Courses)> Select Type as Courses > Create a Block 

2. Enter the Block Title as Courses > Continue and Edit

3.  Under the Advanced > Add Relationships search for Entity Reference: Referencing entity (select the same field which was referenced under school content type) and click on apply

4. Under contextual filter > Search and select Content: Nid and in relationship option select the relationship and under WHEN THE FILTER VALUE IS NOT AVAILABLE
 select as  Provide default value > Content id from URL > Click on apply

5.  And under format or Fields, you can select anything depending on how you want to display the data

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.