Skip to content

Instantly share code, notes, and snippets.

@Saeven
Created October 24, 2014 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Saeven/da7a1a085da381589401 to your computer and use it in GitHub Desktop.
Save Saeven/da7a1a085da381589401 to your computer and use it in GitHub Desktop.
Dynamically Substitute template in ZF2
$eventManager->attach( MvcEvent::EVENT_DISPATCH, function( MvcEvent $e ){
$route_name = 'something';
$new_template = 'something-else';
if( $e->getRouteMatch() && $e->getRouteMatch()->getMatchedRouteName() == $route_name )
$e->getViewModel()->setTemplate( $new_template );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment