How To Create A block content related In Drupal 7 Views

By
César Álvarez's picture
César Álvarez
· 12/11/2015

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"

Drupal - Añadir Filtro Contextual

 

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. "

Drupal - ID de contenido desde URL

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.

Drupal - ID de término de taxonomía desde la URL

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
Share 

Related works

Creatividad de Porsche Turquesa
The digital transformation of one of the most prestigious and influential brands.
Tabla de surf apoyada en una palmera en la playa
A revolution of the surfing experience
How can we help?Get in touch