[SOLVED][Drupal 7] How to create a View of related terms in a block in a Drupal 7?

January 09, 2013 - 16:17

A large number of Drupal 7 users were looking for a way to create a View of related terms in a block in a Drupal 7 website. If you are facing the same situation in your Drupal site and want to know how to create a View of related terms in a block in a Drupal 7 website then continue reading to find out the steps.

Follow the steps below to create a View of related terms in a block.

  • First create a View as a block
  • After creating the View proceed to add the fields and teasers as required.
  • If you are familiar with Views in Drupal 6 then you have to remember that Arguments are known as "Contextual filters" in Drupal 7
  • Now add the filter: "Content: Has taxonomy term ID"
  • Now configure the filter as follows
    • When filter value is NOT in the URL: -> Provide default value
    • Type: Taxonomy Term ID from URL &
    • Check "Load default filter from node page under that
    • Finally check the boxes of the taxonomy terms you want listed here.
  • Save the View and you should get the block of View related items.
  • However you might notice that the current node will be in the View block and obviously you might want it to be excluded
  • To exlude that current node form the block we need to add the sedcond filter.
  • Click [+] button of the contextual filters section
  • Next select Content:Nid
  • Next set the 'When the filter value is NOT in the URL' to 'Provide default argument'
  • After set the "Default argument type' to 'Content ID from URL'
  • Go to "More" and check the "Exclude" box
  • Save the View
  • You can embed the View in your nodes in your Drupal site.

Hope that helps.

The easiest way to solve a Drupal issue is to hand it to the Drupal experts. We can provide a wide range of Drupal services to help you maintain and manage your Drupal websites. Get in touch with us to know more.

Get Drupal updates straight to your inbox

To prevent automated spam submissions leave this field empty.

Post your comments / questions

That was exactly the configuration I needed to get one content type with a term associated (built into a block view) to show on another content type (node) with the same term and not show the other nodes (in the view) if the term wasn't present.

Contextual Filters are pretty tricky, I was almost there, but was trying to proved default argument with PHP. Switching to Content Id from URL was the little push I needed to get it working!

Thank you!!