generatePage

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.

Parameters

  1. \Contao\PageModel $pageModel

    The current page object.

  2. \Contao\LayoutModel $layout

    The active page layout applied for rendering the page.

  3. \Contao\PageRegular $pageRegular

    The current page type object.

Example

// 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 …
    }
}

References