0

How can we move or override the placement of the comments in a node. Usually the comment section is placed inside its content div. My aim is to place this comment section out of its parent div which is usually the node content.

<div class="content">
 <div property="schema:text" ...>
    <p>
        Some Node Contents ...
    </p>
 </div>
 <section rel="schema:comment" ...> <!--move this comment section from here -->
    <h2>Add new comment</h2>
    <span data-big-pipe-placeholder-id="..."></span>
 </section>
</div>
<!-- to here -->

I have my template overrides

  • field--comment.html.twig
  • comment.html.twig
  • page.html.twig

Inside themes/contrib/mytheme/templates

3

Depending on which container you want to escape, you need to use either node.html.twig (recommended) or page.html.twig (harder, unlike node you can't use {{ content.field_comment }} in page).

If you are using node.html.twig (or somehting like node--BUNDLENAME.html.twig) and you manually render {{ content.field_comment }}, then you can avoid double-rendering of comments by rendering the "normal" content using the without filter {{ content|without('field_comment') }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.