On a node template , i am displaying a taxonomy term ( entity ref field ). That taxonomy term has a parent. How can have that info on the html generated , for css purposes ?
The field.html.twig display this:
<div class="article__categorie-article">
<div><a href="/taxonomy/term/27" hreflang="fr">Utilisation de Drupal</a></div>
<div><a href="/taxonomy/term/29" hreflang="fr">Rôle</a></div>
</div>
I would like to have smth like
<div class="article__categorie-article">
<div><a href="/taxonomy/term/27" hreflang="fr" data-parent-tid="2">Utilisation de Drupal</a></div>
<div><a href="/taxonomy/term/29" hreflang="fr" data-parent-tid="4">Rôle</a></div>
</div>
.theme
file, use an alter function. Create a$variables['taxonomy'] = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree('articles');
and then now in the twig file you can use the taxonomy variable. – Armando Silva Sep 26 '20 at 4:55