Allows to override the default front-end page routing process.
The event handler should parse the requested URL string and return the page object (Cms_Page)
and a list of parameters which could be specified in the URL. The event handler should accept a
single parameter - the URL string and return an array with two elements:
- page - the CMS page object.
- params - the array of parameters extracted from the URL.
Even if there are no parameters required for the page, the
params element should be
presented in the result value as an empty array.
The handler can return null or false to use the default LemonStand routing process.
public function subscribeEvents()
{
Backend::$events->addEvent('cms:onBeforeRoute', $this, 'before_route');
}
public function before_route($url)
{
// Always display the iPad product page, regardless of the actual URL
// Return the default product page with the first parameter containing the "ipad" string
$page = Cms_Page::create()->find_by_url('/product');
return array(
'page'=>$page,
'params'=>array('ipad')
);
}