In a drupal block view that I have created I am currently displaying the images and title of a certain content type. On that content type I have two taxonomy term fields one is a multi-select box

My question is this, I want to filter the title and images according to the taxonomy multi box field when a node is displaying, how?

For example if I have a multi list


On creating the node I select water and drupal so when the node displays it will show all the images and titles that have the same taxonomy term in the block view

Below I have an image of a view that is trying to displaying an image and title according to the taxonomy terms save on a node that a user is currently looking at enter image description here

It is not working of course. Do I have the right idea what am I missing?

  • were you able to solve this? or are you still looking for a solution?
    – No Sssweat
    Commented Feb 19, 2015 at 21:12
  • Use "Content: terms on node" relationship in the "term" relationship. Choose the "term" relationship on fields
    – milkovsky
    Commented Feb 23, 2015 at 14:08

3 Answers 3


I would try removing your Content: Related Products filter criteria.

Make sure your contextual Content: Nid filter is setting the default from the content ID in the url, and under "More" this filter is set to exclude.

Add another contextual filter for Content: Has Taxonomy Term ID. Select "Provide default value" and use type PHP Code:

$node = menu_get_object();
$terms = array();
if (empty($node->field_related_products)) return;
foreach ($node->field_related_products[LANGUAGE_NONE] as $term) {
  $terms[] = $term['tid'];

return implode('+', $terms);

Under "More" for this filter, enable "Allow multiple values"

Under "Other > Query Settings" select "Distinct"


I would recommend using Views. You can choose to make it a block or page.

You need Views if

You like the default front page view, but you find you want to sort it differently. You like the default taxonomy/term view, but you find you want to sort it differently; for example, alphabetically. You use /tracker, but you want to restrict it to posts of a certain type. You like the idea of the 'article' module, but it doesn't display articles the way you like. You want a way to display a block with the 5 most recent posts of some particular type. You want to provide 'unread forum posts'. You want a monthly archive similar to the typical Movable Type/Wordpress archives that displays a link to the in the form of "Month, YYYY (X)" where X is the number of posts that month, and displays them in a block. The links lead to a simple list of posts for that month. Views can do a lot more than that, but those are some of the obvious uses of Views.

  • Setup a new View, naming it whatever you want
  • set it to content, of the content type you want to show
  • you probably want it set to Table to determine which fields are presented

Filtering it really depends on how you want to setup the node display. You could use a contextual filter (url parameter) or Filter by the field and expose it allowing the user to change what is displayed. The rest of the answer depends too much on your vision for the page.

  • OP is using a view already.
    – Darvanen
    Commented Feb 17, 2015 at 4:51
  • @Darvanen the original question didn't specify the Views module - it has been edited since
    – Geoff
    Commented Feb 17, 2015 at 5:30
  • Sorry Geoff but the first words of the first unedited version are "In a block view"
    – Darvanen
    Commented Feb 17, 2015 at 5:47
  • that means nothing, I've seen people use 'units' as nodes, 'pages' as content types and 'div' meaning a block - obviously the original question wasn't specific enough for me to assume that. Op will ignore it given the edits made, so what does it matter now...
    – Geoff
    Commented Feb 17, 2015 at 18:35

You should use a taxonomy contextual filter. It will filters all nodes that have the same taxonomy terms as your current node.

If I understand well your issue, i think there is no need to use any PHP here.

In "Contextual Filters" add "Content: Has taxonomy term ID". Then select "Provide default value" and select the "Taxonomy term ID from URL". It opens a few checkbox options. Select "Load default filter from node page". There is a Vocabulary selection list if you want to restrict your query to specific vocabularies.

With those settings selected, the view will list all nodes containing terms that are selected in the current node. You can then add the title and picture field as usual in the Fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.