This is the API docs for LemonStand V1, which has been discontinued. LemonStand is now a cloud based platform, available at lemonstand.com.

LemonStand API

cms:onBeforeRoute event

Triggered by /controllers/application.php
Author LemonStand eCommerce Inc.

Event handler signature

public array event_onBeforeRoute(string $url)
$url string specifies the requested URL string.
{return} array returns an array containing page and params elements.
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')
  );
}