You are here

field--comment.html.twig in Open Social 8.8

Default 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.
  • 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

themes/socialbase/templates/comment/field--comment.html.twig
View source
  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 comment_preprocess_field()
  26. */
  27. #}
  28. {{ attach_library('socialbase/comment')}}
  29. {# extra condition to make sure the card is not shown when there are no comments and comments are closed #}
  30. {% if comments or comment_form %}
  31. <a id="section-comments"></a>
  32. <section{{ attributes }}>
  33. {% if not label_hidden %}
  34. {{ title_prefix }}
  35. {# extra condition to add the count when Ajax is used see src/Plugin/Preprocess/Field.php #}
  36. {% if comment_count is not empty and comment_count > 0 %}
  37. <h4{{ title_attributes.addClass('section-title') }}>{{ label }} ({{ comment_count }})</h4>
  38. {% else %}
  39. <h4{{ title_attributes.addClass('section-title') }}>{{ label }}</h4>
  40. {% endif %}
  41. {{ title_suffix }}
  42. {% endif %}
  43. <div class="card">
  44. <div class="card__block">
  45. {{ comments }}
  46. {% if comment_form %}
  47. {{ comment_form }}
  48. {% endif %}
  49. </div>
  50. </div>
  51. </section>
  52. {% endif %}