Display Referencing Nodes List on Referenced Node Using EVA (Drupal 7)

This is in continuation of the previous tutorials about how to show a add link using prepopulate link. In this, we are going to create a view using EVA to show all the referencing nodes on referenced node (i.e. Show courses offered by colleges).

- create your Views to display the Courses attached to a referencable node (i.e. College) being viewed. This will show all the courses offered by College when the college node is viewed. Here again, EVA (i.e. Entity Views Attachments) comes into play.

- While at admin/structure/views, click the "Add new view" link, name it something like "Attached Courses" and select Show Content of type Task. Uncheck create a page, and leave create a block unchecked.
 
 
- Use the "+Add" button near the top, to add an "EVA Field" display to your newly created View.
 
 

- Under the "ENTITY CONTENT SETTINGS" pane, select "Node" for the "Entity type", select the "College" for Bundles (i.e. the content types that can be referenced by the "field_college_er" Entity Reference field on the Course content type and Leave Arguments at id. Select "Yes" for Show Title to display the title of the View display.


 

 
- Under the "FIELDS", add the fields that you want to display. I only opted to display "Title" for now but I could display more if I wanted - (See the above screenshot).

- Now, create the Contextual filter, so that this Entity Views Attachment display only shows on the College content types referenced by the "field_college_er" field on the Course content type, and to show only the Courses that are attached to the College content type node being viewed.
 
-- Expand the "Advanced" pane, and click the "add" button next to CONTEXTUAL FILTERS to add this Contextual Filter. Select the "Content: college er (field_college_er)" to use as the Contextual Filter.
 
 
 
-- Under When the Filter Value is Not Available, select the "Provide default value" radio button, and then select "Content ID from URL".
 
 
 
-- Under When the Filter Value is Available or a Default is Provided, check the "Specify validation criteria" radio button, select "Content" for the Validator, and then select "College" content types which is basically referenced by the "field_college_er" field on the Course content type.
 
 

-- Leave the select list option for Action to take if filter value does not validate to "Hide view" - as seen above screenshot and Click the Apply button to save the new contextual filter.



Now, after saving this views, go to any college content type node and you should see a list of all courses added to that College content type. You can also change the display of this EVA views by going to "Manage Display" tab on College content type. Here is a screenshot of College node which shows all the courses attached to that college.




No comments:

Post a Comment

Commonly Used Abbreviations Used Daily

Although, we tend to use short form of long words in daily life but there are many abbreviations which we don't remember. Below is the l...