parseArticles
The parseArticles hook is triggered when parsing news articles. It passes the
front end template, the current article and the news module instance as arguments
and does not expect a return value.
Parameters
\Contao\FrontendTemplate
$templateThe front end template instance for the news article (e.g.
news_full).array
$newsEntryThe current news item database result.
\Contao\Module
$moduleThe module instance (e.g.
\Contao\ModuleNewsList).
Example
// src/EventListener/ParseArticlesListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\FrontendTemplate;
use Contao\Module;
use Contao\UserModel;
#[AsHook('parseArticles')]
class ParseArticlesListener
{
public function __invoke(FrontendTemplate $template, array $newsEntry, Module $module): void
{
// Remove the default "by …" from Contao
$template->author = UserModel::findById($newsEntry['author'])->name;
}
}