getPageLayout
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.
Parameters
\Contao\PageModel
$pageThe page model instance.
\Contao\LayoutModel
$layoutThe layout of the page.
\Contao\PageRegular
$pageRegularThe page type instance.
Example
// 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 $page, LayoutModel $layout, PageRegular $pageRegular): void
{
// Modify the page or layout object
}
}