The listComments hook is triggered when listing comment from unknown source in the back end. It passes the current record as argument and expects a string as return value.


  1. array $comment

    The current comment record data.

Return Values

Return a string representing your comment, or an empty string if your method is not responsible for the source table.


// src/EventListener/ListCommentsListener.php
namespace App\EventListener;

use Contao\CoreBundle\ServiceAnnotation\Hook;
use Terminal42\ServiceAnnotationBundle\ServiceAnnotationInterface;

class ListCommentsListener implements ServiceAnnotationInterface
     * @Hook("listComments")
    public function onListComments(array $comment): string
        if ('tl_mytable' === $comment['source']) {
            return '<a href="contao/main.php?do=…">' . $comment['title'] . '</a>';

        return '';