Indicating Depth

If your taxonomy vocabulary represents a hierarchy, you can construct paths to return just a segment of the hierarchy. Consider the following hierarchy:

term 1

term 2

term 3 term 4

term 5

term 6

You already know what the path should look like to get a list of content for tid 1:


This is a shorthand for the longer syntax that follows this form:


Depth is the number of levels in the hierarchy below the tid that should be returned, and it defaults to zero (0). So these two paths are equivalent:

taxonomy/term/1 taxonomy/term/1/0

Now watch what happens when you ask for a depth of 1:


You now get a list that includes content categorized with tids 1, 2, and 6, as these are the direct children of tid 1. Increase the depth to 2, and the list will grow to include tids 3 and 4. A depth of 3 or greater will produce the entire hierarchy. Can you predict which terms this path will produce?


It will list all content that is classified with either tid 4 or 6 or any of their direct children, which includes tid 5.

0 0

Post a comment