0

I have two entities, article and author which are related to each other.

When I display an author I want to display also all articles of him.

I was thinking about a block which is displayed on some url patterns, but I didn't find a way to pass the current entity as filter for the block.
Nevertheless I am not sure if it is a good practice to define blocks and place them in the layout when they are only get rendered on some pages.

How can I display content related to other content?

EDIT:

Trying to use contextual filter:

  • Add a relationship to the other entity, but which one should I use?
    • Content referenced from
    • Content using
  • Add contextual filter using default value, content ID from URL
2
  • how are they related. Are you using an node reference field? – Matt Mar 8 '18 at 14:43
  • @Matt Yes as normal node / entity reference – CSchulz Mar 12 '18 at 9:45
0

You can use Contextual filters on Drupal 8 to pass the current entity as the filter. Have a look at: https://valuebound.com/resources/blog/how-to-use-contextual-filter-in-drupal-8

and https://www.youtube.com/watch?v=FUlj6-Rb7Ds for more details.

3
  • Thanks. Is it a good pratice to use blocks for showing such details on some pages? – CSchulz Mar 8 '18 at 13:56
  • That is the default way of displaying dynamic information on Drupal 8. It is possible to control precisely on which all content types/pages it should appear and which all it should not through the configuration. You can also attach views to displays, in case you are not comfortable with throwing numerous blocks through the block layouts. – Sensimple Mar 8 '18 at 15:46
  • I have updated my question about contextual filters, both relationships doesn't work for me. – CSchulz Mar 12 '18 at 13:29

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.