I need to create a view with contextual filters that displays all nodes below the specified term.


  • Colors
    • Blue
      • Cerulean
      • Slate
    • Yellow
      • Bright
        • Hi-liter
        • Pastel Yellow
      • Not so bright
      • Mustard

(Bold represents nodes)

So "Colors" would list Cerulean, Slate, Hi-liter, Pastel Yellow, and Mustard.

"Yellow" would list Hi-liter, Pastel Yellow, and Mustard.

"Bright" would list Hi-liter and Pastel Yellow.


How can I create a contextually-filtered view of nodes by taxonomy term that takes the entire lineage into account?


You can do this in Views as you said with Contextual Filters.

In your view click "add" next to Contextual Filters and in the modal check "Content: Has taxonomy term ID (with depth)". Then click "Add and Configure" and you will see the "Depth" option. In the case of your color example above your depth would be 2 and when passing "Colors" to the view it would return all the nodes you bolded.

If you want the whole depth if it has great grandchildren and so on you would need to set the depth higher to account for the number of levels of your taxonomy hierarchy. For your example and passing "Colors" as the argument, a depth of 0 would return no nodes, 1 would return "Cerulean, Slate and Mustard", and 2 would return all of the nodes as mentioned above.

Passing the other Colors as arguments would behave in the way you desire.

  • 2
    Note I recently got caught out trying to do this on products (ie not nodes) and it doesn't work. If anyone's interested in that you can use Taxonomy entity index and a patch from this issue. – Andy Aug 7 '12 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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