Hi,

I've created a content type for product reviews. One of the fields of the products is a taxonomy term. E.g. in the taxonomy "Genre" there is "comedy" or "horror".

I would like to find a way to show the related content by the taxonomy term associated to the product.

For example : on the page of the review (content) of a movie (product) of the horror genre (taxonomy), I'd like to show other horror movie reviews. I've tried to work with contextual filters in views, to no avail so far.

Thanks

Comments

wombatbuddy’s picture

Updated (the solution without additional module).

One of a possible way is to create a views block with related content.

1. Add the  'Content: Has taxonomy term ID' contextual filter.
2. Check 'Provide default value' option and then select the 'Taxonomy term ID from URL'.
3. Check the 'Load default filter from node page, that's good for related taxonomy blocks' option.
4. Check the 'Limit terms by vocabulary' option and the check the 'Genre' vocabulary.
5. Also, you need to create the "Content: ID" filter to exclude the current node from the view result.
Select provide default value: Content ID from URL.
6. Scroll down to the bottom of the window and click on the "More" link.
In the more field-set check Exclude.

See the screenshots of the example:
1. https://cdn1.bbcode0.com/uploads/2020/6/25/98f8d775e5d7f8644a7c6590cdacc...
2.  https://cdn1.bbcode0.com/uploads/2020/6/25/217816f8e4676d42a555b275df458...
3. https://freeimage.host/i/Jt7GzQ
4. https://cdn1.bbcode0.com/uploads/2020/6/25/34071947466317fc74a548751f6b8...
5. https://cdn1.bbcode0.com/uploads/2020/6/25/6d1244db2c1fcb8c74ed251c35b83...
6. https://cdn1.bbcode0.com/uploads/2020/6/25/ad2879542f29cd497c1919a6188fa...

shenron_segamag’s picture

Thanks, I'm gonna try this.

mitpatoliya’s picture

Yeah, I agree contextual filter is the way to go. It should work for you.

Check this out.

https://www.drupal.org/node/75626

aharown07’s picture

Thanks for this!

I was confused by this for a while...

2. Check 'Provide default value' option and then select the 'Taxonomy term ID from URL'.

This does not mean you have to do anything special with term path. wombatbuddy's recipe above works perfectly.

Note: It's easy to overlook the 2nd part of step #2 and get stuck. Don't overlook

select the 'Taxonomy term ID from URL'.