How do I filter only the root terms in a vocabulary in a view? I have have a vocabulary structured as so:


Root Alpha


Term Alpha 1
Term Alpha 2


Subterm Alpha 1


Root Beta
Root Gamma


Term Gamma 1
Term Gamma 2



How do I filter the view to show only the root terms of the vocabulary?
Currently my view is displaying the root terms as well as the children (Term * *)

Going forward from that I would like to pass the argument 'Root Alpha' (or its tid, or whatever from a context) and then have it filter to only 'Root Alpha's direct children. (Term Alpha *). Filtering to a depth any further than that would be a bonus.

I can get it to work if I put all my terms in one root term so that the vocab becomes:


True Root


Root Alpha


Term Alpha 1
Term Alpha 2


Subterm Alpha 1


Root Beta
Root Gamma


Term Gamma 1
Term Gamma 2




I'm not sure which vocab structure is more correct, writing this made me realise I have some reading to do apart from figuring this out with views.
For displaying only the root terms, I have a solution which surely will make someone facepalm (at least I did that):


Add a contextual filter to your taxonomy view
Select Taxonomy term: parent term. 

Set it up like this: When a filter value is not available: Provide default value - Fixed value. Set the value to 0.


Yeah, that's all. Terms without parent have 0 here. See the description of the parent field of the taxonomy_term_hierarchy table:


  Primary Key: The {taxonomy_term_data}.tid of the term's parent. 0
  indicates no parent.