The generatePage
hook is triggered before the main layout (fe_page) is compiled.
It passes the page object, the layout object and a self-reference as arguments
and does not expect a return value.
\Contao\PageModel $pageModel
The current page object.
\Contao\LayoutModel $layout
The active page layout applied for rendering the page.
\Contao\PageRegular $pageRegular
The current page type object.
// src/EventListener/GeneratePageListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\PageRegular;
use Contao\LayoutModel;
use Contao\PageModel;
#[AsHook('generatePage')]
class GeneratePageListener
{
public function __invoke(PageModel $pageModel, LayoutModel $layout, PageRegular $pageRegular): void
{
// Do something …
}
}