1

I started to develop my first website with drupal. So far so good, I like this system, but I have one problem: When creating new node, I want to assign all child terms if I select parent term.

Let's say, I have a vocabulary "Plants". In this vocabulary, there are terms with this kind of hierarchy:

Fruits
--- Apples
------- Green
------- Red
--- Pears
------- Green
------- Red
Berries
--- Wild berries
------- Red
------- Blue

Now, when I create a node, I'm using Simple hierarchical select to select terms of this vocabulary. I'm using Views to display nodes. Let's say I want to assign term "Apples" to a node. When I go to view the page and use Filter Criteria Content: Has taxonomy terms (with depth) (exposed) and choose "Apples", I can see my node.

That's OK. But I want my node to appear if I select Green or Red (under term Apples in terms tree). In other words, if I assign term "Apples" in node creation page, I want it to assign all of its child terms also to this node. I.e., if I assign Wild berries, I want terms Red and Blue (childs of Wild berries) to be assigned also. Because right now, by assigning term "Apples" and then filtering by "Apples" gives what I want, but if I filter by Fruits->Apples->Green, I get no results.

1 Answer 1

3

You can use the Taxonomy Term Reference Tree Widget module

This module provides an expandable tree widget for the Taxonomy Term Reference field in Drupal 7. This widget is intended to serve as a replacement for Drupal's core Taxonomy Term Reference widget, which is a flat list of radio buttons or checkboxes and not necessarily fit for medium to large taxonomy trees.

How to use this module

  1. Enable the Term Reference Tree module.
  2. Go to the Manage Fields tab of any fieldable entity (such as a content type, taxonomy term, or user.
  3. Add a new field with a type of Term Reference.
  4. In the widget select box, select Term reference tree.

Note that you can also change any Term Reference field to use the Term Reference Tree widget, by editing that field and selecting Term Reference Tree on that field's Widget Type tab.

2
  • hm, yet another interesting module (which I didn't know about ...)! Commented Sep 27, 2016 at 20:03
  • @Pierre.Vriens yes is very usefull Commented Sep 27, 2016 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.