Views has a documentation example called How to provide a view which contains taxonomy headers. I had copied that code and created a view under the previous version of Views. Now I am using the cvs version of Views. I see that the Views Theme Wizard will generate code for a view, and I'd like to make that code do what the example does, but using the new $vars[$name] syntax. Has this example been updated, or do you have any suggestions?

CommentFileSizeAuthor
#1 VATopic_Export.txt2.23 KBskcombs

Comments

skcombs’s picture

Title: phptemplate_views_view_list_VIEWNAME » phptemplate_views_view_list_VIEWNAME with taxonomy headers
StatusFileSize
new2.23 KB

I rewrote the code, so I don't need help with that. But I am wondering what the comment about Views Arguments means when I select Taxonomy Term ID as it pertains to categories:
"This will display one of the taxonomy terms associated with the node; if taxonomy terms were used to filter or sort, it will be the one that triggered the sort or filter."
It seems that when I pass an argument that is a term with children and grandchildren, not all of the terms get printed as taxonomy headers. And I have specified the depth option. The terms that do get printed as headers are those categories that have child categories. Are these the only terms that "trigger" a filter? And if so, how can I display the leaf terms?

I have attached the exported view for comment.

merlinofchaos’s picture

I think the problem here is that when you use the depth option to filter on a hierarchy, the 'term' field that you see will always be a 'close' one to the node, i.e, one that is 0 terms away, regardless of what term actually triggered the filter. (the filter is an OR on essentially two different fields).

Soooo, to do what you want to do requires a field Views doesn't have yet, which is 'parent term of the current term'. Worse, how that field gets populated would almost certainly be...very very confusing, unfortunately, because the context can change dramatically from view to view.

If this were added (you can experiment, if you like, by editing views_taxonomy.inc; you could add a clone of the term_data table, with the left side of the join linking to term_hierarchy.parent and the right side linking to tid. Have that table export the 'taxonomy: term' field, but call it taxonomy: term parent.

Once you've got that, *then* in your theming function, you'd have to compare which of the two terms match the filter, and use *that* as the header field. You'll need to try and not put items from the same hierarchy in the trigger as they could both match and that'll confuse the code.

So, ah. Welcome to the wonderful world of Views + hierarchical data. The whole thing is a mess, which is why after all this time, taxonomy is the one area that Views still has a few issues.

merlinofchaos’s picture

Status: Active » Closed (fixed)