0

I have two content types: Medical Records and Resident Profile. Each Medical Records node is associated to a Resident Profile through an Associated Resident entity reference field added to the first content type.

enter image description here

In the node display page for the Resident Profile nodes, I want to have a block on the side that displays all the associated Medical Records nodes.

I know I have to do something with the contextual filters and relationships settings of a view, but I am not sure how to proceed.

How can I achieve what I described?

1 Answer 1

0

After creating a view, you can follow these steps to accomplish what you need:

Add a contextual filter, Search for nid - So you will have Content: Nid.

In When the filter value is NOT available:

  • Select Provide default value -> Type -> Content ID from URL.
  • Apply

Add a relationship in your view:

  • Search for field_associated_resident (your machine name), if there are two things come up. choose the one which says something like this: A bridge to the Content entity that is referencing Content via field_associated_resident (Language can differ).
  • Check Require this relationship.
  • Apply

Now go to your field selection, for example, you may want to display title. Add a field title and choose the relation you just created and Save.

To test this, you can use the nid of the Resident profile where you want to display it in the view itself. You should get your expected results there itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.