简体   繁体   中英

How to create a field in Drupal 7 view based on specific taxonomy term?

I am new to Drupal and I have been trying to figure out how to create a field in Drupal 7 views to group my content by a specific taxonomy term. I've already attempted to use the vocabulary this taxonomy term belongs to, but it will also group with other taxonomies under the same vocabulary, which I don't want to do. Essentially what I want to do is this:

Vocabulary

  • taxonomy term parent (show)
    • taxonomy term child
  • taxonomy term parent (ignore/hide)

Right now I can select the vocabulary for the field as content: [vocabulary], but what I want is content: [vocabulary > taxonomy term parent (show)]. How do I do this?

This can be achieved with a relationship using the following steps:

  • Add a relationship to the view, select "Taxonomy term: Parent term" and call the relationship "Parent" (Identifier)
  • Add the field "Taxonomy term: Rendered Taxonomy term"
  • In the field settings under Relationship, select "Parent"
  • In the Format settings add "(Parent) Rendered Taxonomy term" as Grouping field Nr.1.

This will grouped the child terms under their parent terms. Make sure your view is of Taxonomy terms and not Content. You don't need to use the Rendered Taxonomy term field, as long as you select the Relationship in field settings you can control which fields are rendered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM