Question

I have a content type which has a Entity Reference field (field_industry). I am trying to create a menu on a page containing all the nodes which have an enity reference which is the same as the title or URL of the page the view will be displayed in.

EG

I have a page called glass, and 2 pages below which have the Entity reference of "Glass". I have created a view, which shows the title field. If i add a field to the view (field_industry) and set it to =glass. But it needs to be dynamic. How would i do this with "contextual filters"?

Was it helpful?

Solution

The entity reference field stores a reference to the actual node so you do not filter on the string glass you filter on the node id.

If my understanding is correct when you view the glass node you want to show a list of all nodes that reference the glass node.

  1. Create a view showing content of the type you want to display, also create a block with that view.
  2. Add a contextual filter on the field that is used to reference the material.
  3. For "When the filter value is not available" check "provide default value" and then "type" should be "Content ID from URL"
  4. Go to admin/structure/blocks and place the block where ever you need to display it.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top