跳转到主要内容
learningxm 提交于 3 September 2013

http://drupal.stackexchange.com/questions/21459/how-to-show-terms-in-a-views-in-its-hierarchical-structure

 

先做个标记,有时间的时候翻译一下

 

 

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)