I am using Views 3 in Drupal 7 to show parent taxonomy terms using nested relationships.
This involves setting up a parent relationship, then a parent relationship of that parent, and then a parent relationship of that parent - this goes five levels deep and appears to be working well.
I have set the view to output the term name associated with each relationship, and with Views set to not render anything if the result is empty, I am being left with exactly what i need - a list of all (well, five levels right now) hierarchical parent terms. I have also set views to link each of these term names to their respective pages - and this is what is causing me problems...
Thing is, I want to see these fields as an unordered list. Setting the format option in Views to HTML list obviously sees all of my fields as part of the same result, and thus makes them the same list item.
The first thing I tried was to hide each field from display and rewrite everything using a custom text field:
<ul> <li>[Term_Name_Level_1]</li> <li>[Term_Name_Level_2]</li> <li>[Term_Name_Level_3]</li> <li>[Term_Name_Level_4]</li> <li>[Term_Name_Level_5]</li> </ul>
This works, but when I'm not five levels deep in the hierarchy (which is most of the time), I end up with empty li tags, as so:
(I put periods in here to show the effect, as the blank list items don't show here otherwise)
- Grandparent term name
- Parent term name
The next thing I tried was to rewrite each individual term name field, adding li tags around each one
then rewriting the output as follows
<ul> [Term_Name_Level_1] [Term_Name_Level_2] [Term_Name_Level_3] [Term_Name_Level_4] [Term_Name_Level_5] </ul>
This almost worked, as if there is no result, the whole field is left out including the tags. The problem here is that the link to the term page is wrapping around the li tags, like so:
<ul> <a href"#whatever"><li>Grandparent term name</li></a> <a href"#whatever"><li>Parent term name</li></a> </ul>
Thats obviously not what I need, so can anyone think of a way to get Views to output each field as a list item, but without printing empty tags when there is no result? I must say, I have a horrible feeling that I'm overlooking something!
Is there perhaps a way to get Views to output a raw link to each term page, so I can rewrite the lot? I see that there is a 'Taxonomy term: Term edit link' field available, but not a link to the actual term!