You are here

field--comment.html.twig in Drupal 9

Theme override for comment 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 title.
  • label: The label for the field.
  • title_prefix: Additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • title_suffix: Additional title output populated by modules, intended to be displayed after the main title tag that appears in the template.
  • comments: List of comments rendered through comment.html.twig.
  • comment_count: Count of comments rendered through comment.html.twig.
  • content_attributes: HTML attributes for the form title.
  • comment_form: The 'Add new comment' form.
  • comment_display_mode: Is the comments are threaded.
  • comment_type: The comment type bundle ID for the comment field.
  • 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.

File

core/themes/olivero/templates/field/field--comment.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * 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. * - comment_count: Count of comments rendered through comment.html.twig.
  17. * - content_attributes: HTML attributes for the form title.
  18. * - comment_form: The 'Add new comment' form.
  19. * - comment_display_mode: Is the comments are threaded.
  20. * - comment_type: The comment type bundle ID for the comment field.
  21. * - entity_type: The entity type to which the field belongs.
  22. * - field_name: The name of the field.
  23. * - field_type: The type of the field.
  24. * - label_display: The display settings for the label.
  25. *
  26. * @see template_preprocess_field()
  27. * @see comment_preprocess_field()
  28. */
  29. #}
  30. {{ attach_library('olivero/comments') }}
  31. <section{{ attributes.setAttribute('data-drupal-selector', 'comments').addClass('comments') }}>
  32. {% if not label_hidden %}
  33. {{ title_prefix }}
  34. <h2{{ title_attributes.addClass('comments__title') }}>
  35. {{- label -}}
  36. {%- if comments -%}
  37. <span class="comments__count">{{ comment_count }}</span>
  38. {%- endif -%}
  39. </h2>
  40. {{ title_suffix }}
  41. {% endif %}
  42. {% if comment_form %}
  43. <div class="add-comment">
  44. {% if user_picture %}
  45. <div class="add-comment__picture-wrapper">
  46. <div class="add-comment__picture">
  47. {{ user_picture }}
  48. </div>
  49. </div>
  50. {% endif %}
  51. <div class="add-comment__form">
  52. {{ comment_form }}
  53. </div>
  54. </div>
  55. {% endif %}
  56. {{ comments }}
  57. </section>