Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
As things stand now we have a hack in our core comment-wrapper template specifically for forum:
<section id="comments" <?php print $attributes; ?>>
<?php if ($content['comments'] && $node->type != 'forum'): ?>
<?php print render($title_prefix); ?>
<h2 class="title"><?php print t('Comments'); ?></h2>
<?php print render($title_suffix); ?>
<?php endif; ?>
<?php print render($content['comments']); ?>
<?php if ($content['comment_form']): ?>
<h2 class="title comment-form"><?php print t('Add new comment'); ?></h2>
<?php print render($content['comment_form']); ?>
<?php endif; ?>
</section>
It might make more sense for forum module to provide it's own version of this template file, one that inherits from comment-wrapper.twig and removes the title.
Suggested change:
comment-wrapper.html.twig
<section id="comments"{{ attributes }}>
{% codeblock %}
{% if content.comments %}
{{ title_prefix }}
<h2 class="title">{{ 'Comments'|t }}</h2>
{{ title_suffix }}
{% endif %}
{% endcodeblock %}
{{ content.comments }}
{% if (content.comment_form %}
<h2 class="title comment-form">{{ 'Add new comment'|t }}</h2>
{{ content.comment_form }}
{% endif %}
</section>
comment-wrapper--forum.html.twig
{% extends 'comment-wrapper.html.twig' %}
{% codeblock %}
{% endcodeblock %}
Comments
Comment #0.0
jenlamptonUpdated issue summary.
Comment #1
c4rl CreditAttribution: c4rl commentedMoving to core queue and postponing due to #1783184-5: [meta] Use Twig template inheritance
Comment #1.0
c4rl CreditAttribution: c4rl commentedh2
Comment #2
mgiffordBecause #1783184: [meta] Use Twig template inheritance is "works as designed" should this issue be closed now?
Comment #3
joelpittetThis template moved to
field--comment.html.twig
and we can have template suggestions to override this or add a twig block if needed.If you disagree please add notes to the issue summary to why this would help core. A screenshot of before/after would help sell the point I bet, not sure why removing the title is necessary for forums.
Triaging