1

I have a view with a taxonomy term field called Location in Drupal 7 and I want to show the first / root level of the term hierarchy in each view item field, aka the Country level.

My Location field in not mandatory, so I also want to show items with no Location. Meaning that I should mark all my term relationships as not required.

I have tried using relationship to the taxonomy term, and to the parent of the taxonomy term. And then a parent filter on the parent of the taxonomy term with value = empty. By this way I managed to show the root level of my taxonomy field only, but not items with no Location. As trying to make my relationship on taxonomy term not required, throws an exception. I guess this is due to the fact that then it tries to find the parent of the term and if it the term is empty, it throws the exception.

Any suggestions on how could I show the root term (Country) and, at the same time, items with no Location?

1 Answer 1

0

In the 'Fields' section of the view add your taxonomy field (Location). Select the Formatter that you want and then in the settings of the field, in the fieldset 'Multiple field settings' change the 'Display' option from 'all' to '1'.

Enjoy

1
  • It worked! I thought that this option was for multiple values fields only, but it works also for multi-level taxonomy term fields also, regarding each level as a separate value. So, in single-value taxonomy term fields this solution works fine and even with empty values. Moreover, it is easy to implement and does not require relationships.
    – user20765
    May 29, 2014 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.