Friday, November 30, 2018

DRUPAL 8: Block of nodes referencing the current node

we have  contentype Publication and a contenttype Article
The contentype Article references the contenttype Publication
(the referencing field is f.i.  field_editie_s )
Multiple articles reference one Publication

Article --- fied_editie_s ---> Publication

Create a block view on anny  Publication page listing all nodes referencing that page

1.  create view
Administration > Structure > Views > Add a New View
1.1 Create a block view
1.2 Filter on the child element: Article

1.3 add relationship

choose: 'content referenced from field_editie_s'
click: 'add and configure'
select 'require this relationship'

1.4 add contextual filter

under relationship choose: field_editie_s: content
choose ID (content)
click 'add and configure contextual filter
select 'provide default value'
select 'Content ID from URL'
click save

test it by inserting a node is from a publication node in the preview with contectual filters

now show the block on the publicatiosn pages