3

I rewrite the article tpl page--article.html.twig and I want to render the comments and the comments form.

I add the comments in the content type fields and try to render with {{ node.comment | render }}, but it's not work.

Is it possible to render it in a custom tpl?

1

After adding comments as field in your content type

In node--article.html.twig :

{{ content.field_myfieldnamecomments }}

  • It's working for node view, But not for the node preview, How can we show the comment section for node preview as well ? – Manmeet Khurana Jun 27 at 12:41
1

In template files for a content type (eg page--article.html.twig), you have the 'content' variable available. I use this bit of Twig to render the whole comments block:-

{{ content.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.