Embed a view in a node that displays things contextually relevant to that node with EVA- Entity Views Attach
- drupal 8 include view based on node
- Entity Views Attachment vs drupal 8 eva
i could do it only with code but seems more consistent to make it a field like EVA does
https://drupal.stackexchange.com/questions/198868/how-can-i-embed-a-view-inside-a-content-of-a-node
https://api.drupal.org/api/drupal/core!modules!views!views.module/function/views_embed_view/8.8.x
The missing documentation is in this issue (key piece of info: start with creating the view as an Entity View Attachment)
Oh i’ll want this patch too: Hide output if empty option.
https://www.zivtech.com/blog/empowering-drupal-8-content-editors-eva-attach-all-displays
Updates
You always need to add a contextual argument, and you don’t need to change what is done by default if there is no term ID (or other entity ID), EVA will definitely hand one in.
Note you do not always need a relationship. For instance showing the entities that reference another entity is done simply with the reference field as the contextual filter, no relationship needed.
Over on display…
Unfortunately having a normal field label is a lot harder than it should be:
Implement an EVA field label [#2303367] | Drupal.org
Alternatives to EVA
https://www.drupal.org/project/views_field_formatter
https://www.drupal.org/project/viewfield
https://www.drupal.org/project/entity_extra_field
… but none are better maintained nor more used than Entity Views Attach.