title: Use differents layouts to differents modules zend framework 2
body: <p>I am using EdpModuleLayouts to use one layout to mobile version of my zf2 webapp and another to the "desktop" version.</p>
  
  <p>The configuration in module.config.php in Application module:</p>
  
  <pre><code>...'view_manager' =&gt; array(
      'display_not_found_reason' =&gt; true,
      'display_exceptions'       =&gt; true,
      'doctype'                  =&gt; 'HTML5',
      'not_found_template'       =&gt; 'error/404',
      'exception_template'       =&gt; 'error/index',
      'template_map' =&gt; array(
          'module_layouts' =&gt; array(
              'Application' =&gt; 'layout/application',
              'User'        =&gt; 'layout/user',
          ),
          'application/index/index' =&gt; __DIR__ . '/../view/application/index/index.phtml',
          'error/404'               =&gt; __DIR__ . '/../view/error/404.phtml',
          'error/index'             =&gt; __DIR__ . '/../view/error/index.phtml',
      ),
      'template_path_stack' =&gt; array(
          __DIR__ . '/../view',
      ),
  ),
  </code></pre>
  
  <p>Module.php of the Application module it's like this:</p>
  
  <pre><code>public function onBootstrap(MvcEvent $e)
  {
  
      $e-&gt;getApplication()-&gt;getServiceManager()-&gt;get('translator');
      $eventManager        = $e-&gt;getApplication()-&gt;getEventManager();
      $moduleRouteListener = new ModuleRouteListener();
      $moduleRouteListener-&gt;attach($eventManager);
  
  
      $e-&gt;getApplication()-&gt;getEventManager()-&gt;getSharedManager()
      -&gt;attach('Zend\Mvc\Controller\AbstractActionController', 'dispatch', function($e) {
          $controller      = $e-&gt;getTarget();
          $controllerClass = get_class($controller);
          $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
          $config          = $e-&gt;getApplication()-&gt;getServiceManager()-&gt;get('config');
          if (isset($config['module_layouts'][$moduleNamespace])) {
              $controller-&gt;layout($config['module_layouts'][$moduleNamespace]);
              echo $config['module_layouts'][$moduleNamespace];
          }
      }, 100);
  
  }
  </code></pre>
  
  <p>Finally, I have one layout in Application module and another in User module. At this moment every time render the layout in the User Model, even though I enter the Application url.</p>
  
  <p>I stucked on this, I appreciate some help.</p>