field--comment.html.twig 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. {#
  2. /**
  3. * @file
  4. * Default theme override for comment 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 title.
  10. * - label: The label for the field.
  11. * - title_prefix: Additional output populated by modules, intended to be
  12. * displayed in front of the main title tag that appears in the template.
  13. * - title_suffix: Additional title output populated by modules, intended to
  14. * be displayed after the main title tag that appears in the template.
  15. * - comments: List of comments rendered through comment.html.twig.
  16. * - content_attributes: HTML attributes for the form title.
  17. * - comment_form: The 'Add new comment' form.
  18. * - comment_display_mode: Is the comments are threaded.
  19. * - comment_type: The comment type bundle ID for the comment field.
  20. * - entity_type: The entity type to which the field belongs.
  21. * - field_name: The name of the field.
  22. * - field_type: The type of the field.
  23. * - label_display: The display settings for the label.
  24. *
  25. * @see template_preprocess_field()
  26. * @see comment_preprocess_field()
  27. */
  28. #}
  29. <section{{ attributes.addClass('comments') }}>
  30. {% if comments and not label_hidden and (entity.entityType != 'node' or entity.bundle != 'forum') %}
  31. {{ title_prefix }}
  32. <h2{{ title_attributes }}>{{ label }}</h2>
  33. {{ title_suffix }}
  34. {% endif %}
  35. {{ comments }}
  36. {% if comment_form %}
  37. <h2{{ content_attributes.addClass('title') }}>{{ 'Add new comment'|t }}</h2>
  38. {{ comment_form }}
  39. {% endif %}
  40. </section>