The getPageLayout
hook is triggered when a regular page is generated.
It can be used to modify the page or layout object. It passes the page
object, the layout object and the page type instance as arguments
and does not expect a return value.
\Contao\PageModel $pageModel
The page model instance.
\Contao\LayoutModel $layout
The layout of the page.
\Contao\PageRegular $pageRegular
The page type instance.
// src/EventListener/GetPageLayoutListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\PageRegular;
use Contao\LayoutModel;
use Contao\PageModel;
#[AsHook('getPageLayout')]
class GetPageLayoutListener
{
public function __invoke(PageModel $pageModel, LayoutModel $layout, PageRegular $pageRegular): void
{
// Modify the page or layout object
}
}