Last active
June 17, 2016 06:07
-
-
Save JiNexus/2af148e40b1afeb7223432d37e26ae35 to your computer and use it in GitHub Desktop.
Create layout for each module in ZF2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array( | |
// ... | |
'view_manager' => array( | |
'display_not_found_reason' => true, | |
'display_exceptions' => true, | |
'doctype' => 'HTML5', | |
'not_found_template' => 'error/404', | |
'exception_template' => 'error/index', | |
'template_map' => array( | |
'anothermodule/layout' => __DIR__ . '/../view/layout/layout.phtml', | |
'anothermodule/index/index' => __DIR__ . '/../view/anothermodule/index/index.phtml', | |
'error/404' => __DIR__ . '/../view/error/404.phtml', | |
'error/index' => __DIR__ . '/../view/error/index.phtml', | |
), | |
'template_path_stack' => array( | |
'anothermodule' => __DIR__ . '/../view', | |
), | |
), | |
// ... | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AnotherModule; | |
// ... | |
use Zend\ModuleManager\ModuleManager; | |
// ... | |
class Module | |
{ | |
// ... | |
public function init(ModuleManager $moduleManager) | |
{ | |
$$moduleManager->getEventManager()->getSharedManager()->attach(__NAMESPACE__, 'dispatch', function($e) { | |
$e->getTarget()->layout('anothermodule/layout'); | |
}); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment