2013-08-01 66 views

回答

1

One approach by Rob Allen使用在config/autloload.php是这样的:

array(
    'module_layouts' => array(
     'Application' => 'layout/application', 
     'ZfcUser' => 'layout/user', 
    ), 
); 

另一种approach from Evan Coury - 主要作者为ZF2模块系统,IIRC - 使用这个在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); 
    } 
} 

希望其中的一个会为你工作。

相关问题