20

I have create a view to show the terms of the Products vocabulary.

I the view I set:

Format: Html list

Show: field

Fields: Taxonomy term: Name

It works fine but it the hierarchical structure is lost.

The Products vocabulary has this structure:

-Cars

--Ford

--Volvo

-Computers

--Desktop

--Laptop

But in the Views the terms lost the hierarchical structure and are listed like:

-Cars

-Ford

-Volvo

-Computers

-Desktop

-Laptop

What am I missing here??

16

I would recommend that you give a try to Views Tree module which installs a tree-style (adjacency) Views style plugin which allows you to list vocabulary in a hierarchical way.

Comment: Views Preview does not show the tree layout but normal page display does output as a tree.

12

Views Tree is nice for fast and simple hierarchy configuration but it lacks some features like different fields/configuration for different tree levels and grouping

You can get more flexible configuration with Views Field View.

This is the setup I needed for a taxonomy tree of three levels where I needed grouping by top level term.

  1. Create a view of terms with a page display(or any other display)
  2. Add relationship "Taxonomy term: Parent term"
  3. Add Field : Term name(without relationship), Term Name(Parent relationship, excluded from display)
  4. Add Filter Taxonomy term: Parent term (Parent relationship) equal to 0. (show only level 2)
  5. In Format settings, use grouping with field (Parent) Term Name.(to display level 1)
  6. Add A new display (an attachment is good)
  7. Override its fields (just click any field, choose this attachment(overridden) from the select box on top, and then save the field. (this is to avoid recursion)
  8. Override the attachment Contextual filters by adding Taxonomy term: Name (Parent relationship)
  9. Add a view field (Global: View) to your view fields.
  10. Use the attachment in the view field config, and add the token for the term name (not the parent) as the contextual filter value sent to the attachment.

You can remove the relationship from the filter in step 4, this will display the top level in main display, so you can skip grouping (step 5), then add a new display for each level you want to display (control no. of levels to display)

For me this gave almost the same results of Views Tree but with the flexibility I needed.

4

I've solved similar task by using the Taxonomy menu module.

Transform any of your taxonomy vocabularies into existing menus easily!

Features:

  • Custom Menu per vocabulary
  • Uses the Terms default Path
  • Integrate with Views
  • Integrate with Path Auto
  • Customize the menu path to anything using hooks: Developer Documentation for version 6.x-2.x
  • It doesn't interfere with other menu modules
  • I recommend to not use this module if you want to build i18n site. It makes big problem in this case. – deem Dec 21 '13 at 18:30
  • Can you describe in particular which type of problems this module has for i18n site? I had no problem with internationalization with this module. – Peter Lozovitskiy Dec 22 '13 at 1:31
  • If you have i18n taxonomy and i18n menu there is no way to run it properly. You can read about it on the module project site even. There is no support for that. – deem Dec 22 '13 at 9:10
4

You may use the module Views Term Hierarchy Weight Field. It provides a new sort filter to sort terms by their hierarchical order.

3

If you only have 2 level category tree and don't mind losing the ul nested format or hacking away with theme files, you can obtain such a functionality by following:

  1. Adding a "Parent Term" relationship to the View and require it.
  2. Having two "Term Name" fields. One without a relationship, and another hidden from display field using the newly created relationship.
  3. Use the hidden field as a grouping field.

Not sure if it was exactly that which was intended...

  • it is a good try but not exactly what I need. – chefnelone Feb 2 '12 at 22:52
1

Views Hacks has a views_summary_taxonomy submodule that seems to do what you are looking for:

"It displays a hierarchical summary of the taxonomy terms in your view results."

http://drupal.org/project/views_hacks#views_summary_taxonomy

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.