comment-wrapper.html.twig

Default theme implementation for a comments container.

Available variables:

  • comments: List of comments rendered through comment.html.twig.
  • form: The 'Add new comment' form.
  • content: The content-related elements for the comment display. Use 'content' to print them all, or print a subset such as 'content.comment_form'.
  • attributes: Remaining HTML attributes for the containing element. It includes the 'class' information, which includes:

    • comment-wrapper: The current template type, i.e., "theming hook".
    • 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.

The following variables are provided for contextual information.

  • node: The node entity to which the comments belong.
  • display_mode: The display mode for the comment listing, flat or threaded. The constants below show the possible values and should be used for comparison, as in the following example:

  {% if display_mode is constant('COMMENT_MODE_THREADED') %}
    <h3>{{ 'These comments are displayed in a threaded list.'|t }}</h3>
  {% endif %}
  

See also

template_preprocess()

template_preprocess_comment_wrapper()

1 theme call to comment-wrapper.html.twig
comment_node_page_additions in drupal/core/modules/comment/comment.module
Builds the comment-related elements for node detail pages.

File

drupal/core/modules/comment/templates/comment-wrapper.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for a comments container.
  5. *
  6. * Available variables:
  7. * - comments: List of comments rendered through comment.html.twig.
  8. * - form: The 'Add new comment' form.
  9. * - content: The content-related elements for the comment display. Use
  10. * 'content' to print them all, or print a subset such as
  11. * 'content.comment_form'.
  12. * - attributes: Remaining HTML attributes for the containing element.
  13. * It includes the 'class' information, which includes:
  14. * - comment-wrapper: The current template type, i.e., "theming hook".
  15. * - title_prefix: Additional output populated by modules, intended to be
  16. * displayed in front of the main title tag that appears in the template.
  17. * - title_suffix: Additional title output populated by modules, intended to
  18. * be displayed after the main title tag that appears in the template.
  19. *
  20. * The following variables are provided for contextual information.
  21. * - node: The node entity to which the comments belong.
  22. * - display_mode: The display mode for the comment listing, flat or threaded.
  23. * The constants below show the possible values and should be used for
  24. * comparison, as in the following example:
  25. * @code
  26. * {% if display_mode is constant('COMMENT_MODE_THREADED') %}
  27. * <h3>{{ 'These comments are displayed in a threaded list.'|t }}</h3>
  28. * {% endif %}
  29. * @endcode
  30. * - COMMENT_MODE_FLAT
  31. * - COMMENT_MODE_THREADED
  32. *
  33. * @see template_preprocess()
  34. * @see template_preprocess_comment_wrapper()
  35. *
  36. * @ingroup themeable
  37. */
  38. #}
  39. <section{{ attributes }}>
  40. {% if comments and node.type != 'forum' %}
  41. {{ title_prefix }}
  42. <h2 class="title">{{ 'Comments'|t }}</h2>
  43. {{ title_suffix }}
  44. {% endif %}
  45. {{ comments }}
  46. {% if form %}
  47. <h2 class="title comment-form">{{ 'Add new comment'|t }}</h2>
  48. {{ form }}
  49. {% endif %}
  50. </section>

Related topics