Skip to content

Instantly share code, notes, and snippets.

@kaiohken1982
Created September 21, 2012 12:53
Show Gist options
  • Save kaiohken1982/3761293 to your computer and use it in GitHub Desktop.
Save kaiohken1982/3761293 to your computer and use it in GitHub Desktop.
Zend framework 2 specific layout for a module
<?php
namespace MyModule;
use Zend\ModuleManager\ModuleManager;
class Module
{
public function init(ModuleManager $moduleManager)
{
$sharedEvents = $moduleManager->getEventManager()->getSharedManager();
$sharedEvents->attach(__NAMESPACE__, 'dispatch', function($e) {
// This event will only be fired when an ActionController under the MyModule namespace is dispatched.
$controller = $e->getTarget();
$controller->layout('layout/alternativelayout');
}, 100);
}
}
// http://blog.evan.pro/module-specific-layouts-in-zend-framework-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment