How to setup view using a relationship?

by user2951257   Last Updated January 12, 2018 23:07 PM

We have two content types: basic and article where article has an Entity Reference field that links to the basic page.

The goal is to create a view where we have an exposed filter to allow for a user to search for any basic node for which an article is linked to and return all the Article's fields in any HTML format (tablet, list, etc).

Content Type fields:

Basic page:

  1. title
  2. field_custom_field (textarea)
  3. body

Article Page:

  1. title
  2. field_ent_ref_basic_page (Reference Type = Basic Page)
  3. body
  4. field_asset_type

View Settings:

  1. Format = Entity Reference List
  2. Fields displayed include title and asset type
  3. Relationship = content using field_ent_ref_basic_page (require relationship)
  4. Context filter = field_ent_ref_basic_page
    1. when the filter value is not available -->provide default value -->content id from URL

Expected output:

  1. Basic page1 (nid=1)
  2. Basic page2 (nid=2)
  3. Basic page3 (nid=3)

  4. Article page1 (nid=4) -->field_ent_ref_basic_page = basic page1 (nid=1)

  5. Article page2 (nid=5) -->field_ent_ref_basic_page = basic page2 (nid=2)
  6. Article page3 (nid=6) -->field_ent_ref_basic_page = basic page2 (nid=2)
  7. Article page4 (nid=7) -->field_ent_ref_basic_page = basic page3 (nid=3)
  8. Article page5 (nid=8) -->field_ent_ref_basic_page = basic page1 (nid=1)

If a user types "basic page1" in the exposed filter then the results should be article page1, article page5

Current behavior:

  1. Zero results
  2. when i changed the contextual filter to "when the filter value is not available = display all results for the specified field", i get results.


Related Questions



View - change format

Updated April 13, 2016 08:03 AM

Content type with Quiz field

Updated April 22, 2017 00:07 AM


Show custom banner per page

Updated September 14, 2016 09:03 AM