Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii framework - nested modules

Tags:

module

yii

I am trying to define nested modules, but I couldn't find any complete explanations in the tutorials.

I have a module admin and I want to add another module inside it imgManager, here is my directory structure:

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

I defined the nested modules in my main config file like this:

'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',
                          ),
                    ),
            ),      
),

And here is my 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>',

        ),
    ),

I need to access to this nested module like this: mydomain.com/admin/imgManager but I get Error 404 Unable to resolve the request "admin/imgManager". Where am I doing wrong?

like image 395
mahsa.teimourikia Avatar asked Feb 24 '26 18:02

mahsa.teimourikia


1 Answers

I had to define the module also in here:

class AdminModule extends CWebModule
{
     public function init()
     {
           ...
           $this->setModules(array('imgModule'));
         }
         ...
}
like image 110
mahsa.teimourikia Avatar answered Feb 27 '26 09:02

mahsa.teimourikia