Drupal - View for Entity Reference reverse, backwards forwards
- No additional module need to be installed.
- No coding needed. Just site building for Drupal 8.
- First we need to check if our content types are ready.
Landing page content type, don't need any change. Page content type need a field of type Entity reference.
- Add field -> Add a new field = Reference Content
Then in Edit tab chose your kind of content type (parent)
After Save you will get...
Now go to admin/structure/views and + Add view
In this case we are going to check the option to create a block
In ADVANCED
Add Relationship for our field_back_parent in Page content type. This important to connect the two content types.
You need to tick Require this relationship.
In ADVANCED
Then Add Contextual filter for our current content type Landing Page. In this way, we will get our actual node id to be used in the view. So, now we can find only the pages that have same node id in field_back_parent.
So find by ID (Content)
Select the relationship name.
Check Provide default value -> Content ID from URL
Then you will get something like this:
In Relationship you must to have the word Content in the rightside
This is the result of our settings
If you click in Update preview you will corroborate that it doesn't display anything.
You must to add the node id from parent. In our case is the node 2 from Landing page.
Other way for reference https://mushtaqtahir.com/blog/4/drupal-8-reverse-entity-reference-in-view
I hope that this info help you.