2012-06-18 148 views
3

我想定義嵌套模塊,但在教程中找不到任何完整的解釋。Yii框架 - 嵌套模塊

我有一個模塊admin,我想添加其他模塊裏面imgManager,這裏是我的目錄結構:

protected 
    ... 
    modules 
     admin 
      ... 
      modules 
       imgManager 
      ... 
    ... 

我定義嵌套模塊在我的主配置文件是這樣的:

'modules'=>array(
    ... 
      'admin'=> array(
       'modules'=>array( 
        'imgManager' => array(
         'import'=>array('imgManager.*','imgManager.components.*'), 
         'layout'=>'application.views.layouts.column1', 
         'upload_directory'=>'gal_images', 
         'max_file_number' => '10',//max number of files for bulk upload. 
         'max_file_size' => '1mb', 
         ), 
        ), 
      ),  
), 

這裏是我的urlManager:

'components'=>array(
    ... 
    'urlManager'=>array(
     'urlFormat'=>'path', 
        'showScriptName'=>false, 
     'rules'=>array(
        'admin'=>'admin', 
        'admin/<controller:\w+>'=>'admin/<controller>', 
        'admin/<controller:\w+>/<action:\w+>'=>'admin/<controller>/<action>', 

      '<controller:\w+>/<id:\d+>'=>'<controller>/view', 
      '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', 
      '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 

     ), 
    ), 

我需要訪問這樣的嵌套模塊:mydomain.com/admin/imgManager但我得到Error 404 Unable to resolve the request "admin/imgManager".我在哪裏做錯了?

回答

4

我只好也定義模塊在這裏:

class AdminModule extends CWebModule 
{ 
    public function init() 
    { 
      ... 
      $this->setModules(array('imgModule')); 
     } 
     ... 
} 
+0

這是確定接受你自己的答案 –