Comments rendering can be done with the ez_comments.renderer
service or with the Twig helper.
Useful if you want to attach comments to a given content object.
Twig
{{ ez_comments_render_content( content.contentInfo ) }}
PHP
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
/** @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo */
$commentsRenderer = $container->get( 'ez_comments.renderer' );
$commentsRenderer->renderForContent( $contentInfo );
Useful if your comments are based on the current request (e.g. from a custom controller).
Twig
{{ ez_comments_render() }}
PHP
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
$commentsRenderer = $container->get( 'ez_comments.renderer' );
$commentsRenderer->render();
You can always override options that are set in your configuration:
{# Assuming you're using facebook provider #}
{{ ez_comments_render_content( content.contentInfo, {'num_posts': 20, 'color_scheme': 'dark'} ) }}
Available options depends on each provider. Take a look at providers configuration to learn which options are available.
When rendering comments, you can explicitly specify which comments provider you want to use instead of using the default one.
{{ ez_comments_render_content( content.contentInfo, {}, 'facebook' ) }}