To include comments to any content you want just add following snippet into your html.twig
file.
Following example works for a page:
{{ render(path('sulu_comment.get_threads_comments', {
threadId: 'page-' ~ uuid,
referrer: app.request.uri,
threadTitle: 'This is my thread title',
_format: 'html'
})) }}
But you can use any thread id you want just replace page
by any type.
This will render a form to add new comments to the page and a list of existing ones.
To customize the templates for all types you can use following config:
sulu_comment:
default_templates:
comments: '@SuluComment/WebsiteComment/comments.html.twig'
comment: '@SuluComment/WebsiteComment/comment.html.twig'
If you only want to customize the templates for the example page
type:
sulu_comment:
types:
page:
templates:
comments: '@SuluComment/WebsiteComment/comments.html.twig'
comment: '@SuluComment/WebsiteComment/comment.html.twig'
To extend the form you can provide a FormExtension
for Sulu\Bundle\CommentBundle\Form\Type\CommentType
.
By default comments can be nested in the default implementation. If you want to disable it use following configuration:
sulu_comment:
nested_comments: false
Or for a single type (here page
):
sulu_comment:
types:
page:
nested_comments: false