Score:0

How can I view the list of referenced nodes when viewing a node?

us flag
J.g

I have a content type with a Related pages field, which an entity reference field for nodes.

How can view those nodes while still on the current node?

I tried to achieve this by creating a block view, but this shows all the nodes, whereas I want only the nodes referenced by the Related pages field.

screenshot

Kevin avatar
in flag
You need a contextual filter of the current node.
J.g avatar
us flag
J.g
I tried adding a contextual filter for field_related_documents but then nothing shows up, I'm not really sure how to use the contextual filter.
Score:2
mx flag

You don't need Views to do this, although it is possible to make it work with the correct configuration.

The easiest way is to configure what your Entity Reference field should display.

Configure "Manage display" for the ER field

Go to the Manage display page of your Content Type (admin/structure/types/manage/[myCT]/display/) and change your "Related pages" field to Rendered entity instead of Label.


Use Display modes

If you want to limit which fields of the referenced pages are shown on the page that references them, you can create a new Display mode (under Structure menu) where only the fields you want are enabled. Then use that mode on the ER field settings instead of the "Rendered entity".


Use Views Block with ER Relationship and Contextual filter

If you want to do it through Views to show the Parent fields on the Child node you need to add the Relationship for the ER field, then add the Contextual filter for the ID and Provide default value Content ID from URL, and when using fields make sure they use the Relationship to show the data from the referenced pages and not the (child) page you're currently viewing.

apaderno avatar
us flag
Furthermore, an entity reference field can use a view to show the list of referenced entities.
J.g avatar
us flag
J.g
I am aware that this can be accomplished in other ways, but for other reasons, I believe I need to through views. I followed your steps, but now when I try to add a related document, I'm getting an error: "This entity (node: 1574) cannot be referenced."
mx flag
I've never encountered that error. You need to update your question with all the information.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.