I'm trying to create a view that will display a number of nodes sorted by their parent terms.

For instance, if my terms have the following hierarchy:

- Fruit

I would ideally like to get two 'headings', one for Fruit, one for Vegetables and then list nodes with any sub-term in those sections.

I have tried using view relationships and contextual filters but I just feel lost. What should I do?

Thank you!

  • 1
    Filter by parent term = null – ar7max Aug 21 '15 at 16:49
  • @ar7max Your answer is for a contextual filter correct? – tenken Aug 21 '15 at 17:52
  • Hi, Vecta. Are these filtered (e.g. mypage/fruit displays nodes in the fruit group) or are you looking for an expansive, grouped list? – othermachines Aug 21 '15 at 18:15
  • @othermachines I'd like it to be an expansive list of the parent categories available—a list someone could view to see that they could view "Fruits" or "Vegetables" and then navigate further into the site. – Vecta Aug 21 '15 at 19:00

Go to your view settings. Add term relationship - your term field. Add Filter critera - Parent term. Operator 'equal' value - leave empty parent

| improve this answer | |

You first need to relate the child term to the parent, and then use the grouping feature to group nodes by the parent term.

The tricky part about this is that it only works to a depth of 2. If a term is a parent at any depth it will be added to the group. To explain, in the example below "apples" would also be considered a parent and so you would end up with an "apples" group in addition to fruit and vegetables. (If anyone out there knows how to limit the grouping of parents by depth, leave a comment.)

This won't work:

- - bananas
- - apples
- - - - granny smith
- - - - macintosh
- - carrots

This works:

- - bananas
- - apples
- - oranges
- - carrots

View Set-up


Content: Taxonomy terms on node

             Vocabularies .. [select]
               Identifier .. "child"

Taxonomy term: Parent term

             Relationship .. child
               Identifier .. "parent"
Require this relationship .. [checked]


Content: Title

No special settings

Taxonomy Term: Name

             Relationship .. parent
     Exclude from display .. [checked]


Format: Settings

      Grouping field Nr.1 .. (parent) Taxonomy Term: Name

Query settings (Other)

                 Distinct .. [checked]

Note: The above settings reduces duplicates. If for some reason this causes issues or you're looking for more fine-grained control, use Aggregation (under "Other").

Hope that helps!

| improve this answer | |

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.