1

On my Drupal 9 site, I created taxonomy terms in the "tags" vocabulary (the vocabulary and the default field of the "article" content type) :

enter image description here

When I create a node, I select a taxonomy term in the form (for example "ICO"). The node displays the "tags" field :

enter image description here

I want that if the node has the term "ICO", it also displays the parent terms. Like this :

Catégories : Culture geek, crypto, ICO

How can I do this? I did not find anything in the view mode regarding this field.

5
  • Did you come across this contrib? drupal.org/project/hierarchical_term_formatter Nov 28, 2021 at 13:07
  • @StefanosPetrakis It works thank you
    – mathieu
    Nov 28, 2021 at 15:44
  • Lovely, it would be great to post what worked for you here as an answer, to assist others that land here with the same question. Nov 28, 2021 at 18:07
  • @StefanosPetrakis I cannot answer my own question. You must make an answer and I validate it
    – mathieu
    Nov 28, 2021 at 18:11
  • sorry, thought you could. I will post one in the next couple of minutes. Nov 28, 2021 at 18:22

1 Answer 1

2

You need a field formatter for that, luckily there is one already that covers this use case, it's the Hierarchical Term Formatter that works with Drupal 9.

  1. For the given taxonomy structure:

enter image description here

  1. By selecting the terminal term (in this example 'jodri')

enter image description here

  1. Installing the Hierarchical Term Formatter, with its default configuration

enter image description here

  1. Results in the following display of the rendered node.

enter image description here

Your Answer

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

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