field--node--field-tags.html.twig

Same filename in this branch
  1. 9 core/themes/olivero/templates/field/field--node--field-tags.html.twig
Same filename and directory in other branches
  1. 11.x core/themes/olivero/templates/field/field--node--field-tags.html.twig

Bartik theme override for taxonomy term fields.

Available variables:

  • attributes: HTML attributes for the containing element.
  • label_hidden: Whether to show the field label or not.
  • title_attributes: HTML attributes for the label.
  • label: The label for the field.
  • content_attributes: HTML attributes for the content.
  • items: List of all the field items. Each item contains:
    • attributes: List of HTML attributes for each item.
    • content: The field item's content.
  • entity_type: The entity type to which the field belongs.
  • field_name: The name of the field.
  • field_type: The type of the field.
  • label_display: The display settings for the label.

See also

template_preprocess_field()

File

core/themes/bartik/templates/field--node--field-tags.html.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Bartik theme override for taxonomy term fields.
  5. *
  6. * Available variables:
  7. * - attributes: HTML attributes for the containing element.
  8. * - label_hidden: Whether to show the field label or not.
  9. * - title_attributes: HTML attributes for the label.
  10. * - label: The label for the field.
  11. * - content_attributes: HTML attributes for the content.
  12. * - items: List of all the field items. Each item contains:
  13. * - attributes: List of HTML attributes for each item.
  14. * - content: The field item's content.
  15. * - entity_type: The entity type to which the field belongs.
  16. * - field_name: The name of the field.
  17. * - field_type: The type of the field.
  18. * - label_display: The display settings for the label.
  19. *
  20. * @see template_preprocess_field()
  21. */
  22. #}
  23. {%
  24. set classes = [
  25. 'field',
  26. 'field--name-' ~ field_name|clean_class,
  27. 'field--type-' ~ field_type|clean_class,
  28. 'field--label-' ~ label_display,
  29. 'clearfix',
  30. ]
  31. %}
  32. {%
  33. set title_classes = [
  34. 'field__label',
  35. label_display == 'inline' ? 'inline',
  36. ]
  37. %}
  38. <div{{ attributes.addClass(classes) }}>
  39. {% if not label_hidden %}
  40. <h3{{ title_attributes.addClass(title_classes) }}>{{ label }}</h3>
  41. {% endif %}
  42. <ul class="links field__items">
  43. {% for item in items %}
  44. <li{{ item.attributes }}>{{ item.content }}</li>
  45. {% endfor %}
  46. </ul>
  47. </div>

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.