You can create a Block that displays Child and Grandchild terms (in terms of hierarchy within a Taxonomy Vocabulary) on a taxonomy term pages with the use of an additional module Views Contextual Filters OR to tell the Views to show children
Contextual filters always work with the
AND operator, so this module is necessary to loosen that circumstance.
- Create View of type
- Filter it to show only the Food Vocabulary
To show Children of a term on that term page we can use the Parent term Contextual filter with these options:
When the filter value is NOT available
Provide default value
Taxonomy term ID from URL
Load default filter from term page
When the filter value IS available or a default is provided
Specify validation criteria
Taxonomy term ID
Now if you enter a term ID into Preview you will see the Child terms of that term. This takes care of the Parent-Child.
- To filter Grandchildren we have to introduce that level of connections into View. Add the Parent Relationship
- Add another Parent Relationship and make it use the first one, this is how we get Grandparent info
Add a new Contextual filter Term ID and make it use the second Parent Relationship and other options the same as above.
Now if you enter
all/[TID] you will see the grandchildren terms of the [TID].
To make the Contextual work with
OR go to Query settings and enable Contextual filters OR option.
To test enter the term ID twice into Preview
- Add the Field Name from the Taxonomy term Category and make it use the first Parent Relationship (that is the Parent, not the Grandparent), you can
Exclude it from display later
- Under Format Settings set the Grouping field Nr.1 set the Parent field (you might want to use the
HTML List as the Format)
The results will show the grandparent first and its children, then grandchildren under their parents.
If the grandparent showing their children is not necessary for you, which it probably isn't, because it will be implied from circumstances by being on the grandparent page, you can edit the Filter from step 2 and make it use the second Parent Relationship, this will only show Grandchildren grouped by Parents.
Place the Block in a region and limit the Pages to
Alternatively you'd have to use Views Field View to insert one view into another, which can be performance heavy. I'm not sure how the above compares, it does use some LEFT JOINs too which aren't so performance friendly.