How can we help?Get in touch
As usual in Drupal, there are always several ways to solve a problem. In this case we want to make a block content related to be displayed on a node, for example the typical block of related news shown in the node of a story.
What we need to do is to create a view that shows the news with the same taxonomy term that the node on which the block will be displayed and, of course, that it doesn’t show us the same node we are.
For this we must follow these steps:
1. Create a view with a block type display.
2. We add the fields you want to appear as the title, date and photo.
3. We add a context filter to exclude the current node. Click on "Add contextual Filter"
Select "Content: Nid (The node ID)". Now if the filter is not available, select "Provide default" and Type select "Content ID from URL" Finally we go to the "More" section and check the "Exclude box - If checked, the numbers indicated for the filter will be excluded rather than limiting the view. "
4. We add a second contextual filter:
Select "Content: It has an id from a taxonomy term."
When the filter is not available select "Provide default" and Type select "ID taxonomy term from URL" and then mark the box "Load default filter from node page, that's good for related taxonomy blocks" and select the vocabulary we want. If you do not load the list of vocabularies, click Save and re-click on the conceptual filter.
5. Now you only have to go to the block settings and locate the block in the region and the type of content that interests you.
And that’s it, we have our block content related to views in Drupal 7.
Main photo: Nicolas Hoizey