cms.page.beforeDisplay

Provides an opportunity to swap the page that gets displayed immediately after loading the page assigned to the URL.

Example usage:

Event::listen('cms.page.beforeDisplay', function ((\Cms\Classes\Controller) $controller, (string) $url, (\Cms\Classes\Page) $page) {
    if ($url === '/tricked-you') {
        return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
    }
});

Or

$CmsController->bindEvent('page.beforeDisplay', function ((string) $url, (\Cms\Classes\Page) $page) {
    if ($url === '/tricked-you') {
        return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
    }
});

Usage

Triggers

Class or file Line
Cms\Classes\Controller 190
Copyright © 2024 Winter CMS