Drupal: Creating a Related/Similar View block with Taxonomy

on

Often when displaying a node in Drupal, such as a news article, event or profile page, it is useful to display a few related pieces of content. This can be achived by using a taxonomy field on your content and a view.

To create a view to display other nodes with the same taxonomy term as the current node

  1. Create a view and use a block display.
  2. Add fields to display (title, a small image, date, whatever you like) or just use the node teasers.
  3. Add the contextual filters: Content: Has taxonomy term ID (with depth) and Content: Has taxonomy term ID depth modifier
  4. Set the following configuration options on this filter:
    • When the filter value is NOT in the URL:
      • Provide default value
      • Type: Taxonomy Term ID from URL
    • Under that, check the box Load default filter from node page, that’s good for related taxonomy blocks.
    • Now check the boxes of the taxonomies you want involved here
  5. Now you need to add the second filter in order to exclude the current node from the list. Click [+] button of the contextual filters section to add a new one.
  6. Select Content: Nid
  7. Set the when argument is not present option to Provide default argument
  8. Set the Default argument type to Content ID from URL
  9. Go to MORE and check the Exclude box.
  10. Move the filter Content: Nid to the top position.
  11. Add a block to your view and embed the block on your node pages
  12. Save your view

Leave a Reply

Your email address will not be published. Required fields are marked *