Skip to content

Instantly share code, notes, and snippets.

@MichaelGooden
Last active December 22, 2015 03:39
Show Gist options
  • Save MichaelGooden/6411506 to your computer and use it in GitHub Desktop.
Save MichaelGooden/6411506 to your computer and use it in GitHub Desktop.
Set layout from route param.
<?php
public function onBootstrap(MvcEvent $e)
{
$em = $e->getApplication()->getEventManager();
$em->attach('dispatch', array($this, 'chooseLayout'));
}
public function chooseLayout(MvcEvent $e)
{
$matches = $e->getRouteMatch();
$layoutScript = $matches->getParam('layout');
if ($layoutScript) {
$e->getViewModel()->setTemplate($layoutScript);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment