3

How can I change the way that comments are displayed on my Drupal 8 page?

I can modify the display of some of the fields at

/admin/structure/comment/manage/comment/display

but this allows for rather limited changes only, e.g. doesn't allow changes to titles and links.

I can create my own view to get a custom layout for the comments, but currently ctools, layout_plugin, and page manager for Drupal 8 are still an alpha release, and therefore I can't attach the view as a panel to my node.

Anyone got any ideas how to solve this? Where could I modify the display of my comments programmatically?

2
  • I see you have already answered your question and it is a valid solution. However, would you elaborate and say what exactly you would like to modify ? Maybe there will be another way to achieve the same goal, without modifying the templates. Commented Mar 12, 2017 at 1:26
  • I wanted to have the title displayed in a different size (h3 rather than h2), and have author name and creation date on separate lines below the title. Commented Mar 17, 2017 at 18:40

1 Answer 1

4

Take /core/modules/comment/templates/comment.html.twig file from your Drupal installation directory and place it in the directory of the theme that you are using in the templates folder, for example /themes/bootstrap/templates/. Modify that file to change the way your comments are displayed. You might have to clear the cache to see your changes.

It may be worth creating a sub theme first, so that you don't loose your changes when you update the theme.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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