Use differents layouts to differents modules zend framework 2 -


i using edpmodulelayouts use 1 layout mobile version of zf2 webapp , "desktop" version.

the configuration in module.config.php in application module:

...'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(         'module_layouts' => array(             'application' => 'layout/application',             'user'        => 'layout/user',         ),         'application/index/index' => __dir__ . '/../view/application/index/index.phtml',         'error/404'               => __dir__ . '/../view/error/404.phtml',         'error/index'             => __dir__ . '/../view/error/index.phtml',     ),     'template_path_stack' => array(         __dir__ . '/../view',     ), ), 

module.php of application module it's this:

public function onbootstrap(mvcevent $e) {      $e->getapplication()->getservicemanager()->get('translator');     $eventmanager        = $e->getapplication()->geteventmanager();     $moduleroutelistener = new moduleroutelistener();     $moduleroutelistener->attach($eventmanager);       $e->getapplication()->geteventmanager()->getsharedmanager()     ->attach('zend\mvc\controller\abstractactioncontroller', 'dispatch', function($e) {         $controller      = $e->gettarget();         $controllerclass = get_class($controller);         $modulenamespace = substr($controllerclass, 0, strpos($controllerclass, '\\'));         $config          = $e->getapplication()->getservicemanager()->get('config');         if (isset($config['module_layouts'][$modulenamespace])) {             $controller->layout($config['module_layouts'][$modulenamespace]);             echo $config['module_layouts'][$modulenamespace];         }     }, 100);  } 

finally, have 1 layout in application module , in user module. @ moment every time render layout in user model, though enter application url.

i stucked on this, appreciate help.

i using edpmodulelayouts multi-layout project. think, need move module_layouts module.config.php autoload/global.php file.

this module.php of application module :

public function onbootstrap(mvcevent $e) {     $eventmanager        = $e->getapplication()->geteventmanager();     $eventmanager->getsharedmanager()->attach('zend\mvc\controller\abstractactioncontroller', 'dispatch', function($e) {         $controller      = $e->gettarget();         $controllerclass = get_class($controller);         $modulenamespace = substr($controllerclass, 0, strpos($controllerclass, '\\'));         $config          = $e->getapplication()->getservicemanager()->get('config');         if (isset($config['module_layouts'][$modulenamespace])) {             $controller->layout($config['module_layouts'][$modulenamespace]);         }     }, 100);     $moduleroutelistener = new moduleroutelistener();     $moduleroutelistener->attach($eventmanager); } 

this config\autoload\global.php :

return array(    'db' => array(        .........    ),    'service_manager' => array(        ...........    ),    'module_layouts' => array(        'application' => 'layout/layout.phtml',        'mymodulename' => 'layout/mymodulename.phtml',    ), ); 

it works me , hope helps you.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -