0

I want to filter a View by content type 'Article' and only content that is referenced to a specific node id 123. I have a Paragraph in Article content type. Inside the Paragraph is an entity reference 'my_field' to content and also a few other text fields. In my View I added a relation: Paragraph referenced from my_paragraph_field. I can now add a normal View field - my_field and use the relation. But it doesn't display results of the field. I can also add a filter - my_field and make it equal to nid '123'. But it doesn't filter on the result? How can I make this work. Is this related to this issue. I can create a new View that displays Paragraphs and I can filter on that reference field without adding a relation.

0

The way to list nodes that reference the one you're currenty viewing is by adding a Contextual filter for the Entity reference field that connects them.

You have one more connection in between - the Paragraph. You already added the Relationship to it so you're half way there.

Now that you have the 'my_field' available you need to add the Contextual filter for that field. Configure it to Provide default value, Content ID from URL, and set the other options in a way that makes sense in your particular case.

This will give you a Views Display that is sensitive to the context of the node you're currently viewing, and it will show all the other nodes that reference this node through their Paragraphs.

Usually this Views Display is a Block that you then put in a region of your theme to be displayed on Articles only, and don't forget to set the Block contextual option too.

If you're using regular Filters like you mentioned to filter only node 123, the normal fields will display its info, and not the info from the node that refereces node 123. To display "the child" node info that references the filtered node you have to make the fields use the Relationship for it. Either add the 'my_field' Field (it will automatically use the Paragraph Relationship), and if that won't work you need to add another Relationship that introduces that node info into the Views, then you'll be able to add the Title field for example, and make it use the second Relationship to show the node that references the current node.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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