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.
array $comment
The current comment record data.
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\DependencyInjection\Attribute\AsHook;
#[AsHook('listComments')]
class ListCommentsListener
{
public function __invoke(array $comment): string
{
if ('tl_mytable' === $comment['source']) {
return '<a href="contao/main.php?do=…">' . $comment['title'] . '</a>';
}
return '';
}
}