Question

I am new to YII frame work.

My directory structure is : Protected >> Modules

I have 2 modules site, admin inside the modules folder

Each module have model, view, controller folders

Config is available inside the protected.

If i open siteurl/admin

then i need to call the admin controller inside the admin module

If i open siteurl/

then i need to calll the site controller inside the site module.

In config i can able to set the default controller. But depending on the url the controller need to change. How to implement this.

I tried the following code

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

I able to call either admin controller or site controller. How to do this. Please help me.

No correct solution

OTHER TIPS

Example:

'rules' => array(
'admin/' => 'admin/admin', 
//Call module "Admin" controller "Admin" action "Index" or Default action
'admin/<controller:\w+>/<action:\w+>' => 'admin/<controller>/<action>',
'' => "site/site/idex", 
//If empty path call Modue site controller site action "index"
'<action:\w+>' => "site/site/<action>", 
enter code here//If empty path call Modue site controller site action <action>
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top