file field--comment.html.twig

Theme override to display 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.
  • 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

templates/field/field--comment.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override to display 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. * @see uikit_preprocess_field__comment()
  28. */
  29. #}
  30. {% if comments or comment_form %}
  31. <hr>
  32. {% endif %}
  33. <section{{ attributes }}>
  34. {% if comments and not label_hidden %}
  35. {{ title_prefix }}
  36. <h2 id="comments"{{ title_attributes.addClass('uk-margin-remove') }}>{{ label }} ({{ comment_count }})</h2>
  37. {{ title_suffix }}
  38. {% endif %}
  39. {% if comments %}
  40. <ul class="uk-comment-list">
  41. {{ comments }}
  42. </ul>
  43. {% endif %}
  44. {% if comment_form %}
  45. <h2{{ content_attributes.addClass('uk-margin-top') }}>{{ 'Add new comment'|t }}</h2>
  46. {{ comment_form }}
  47. {% endif %}
  48. </section>

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Log in