Hello,
I’m using Yii-boilerplate and Yii-user extensions, my application’s directories are as follow (simplified to this problem):
/common
/config
/modules
/user
/controllers
/frontend
/config
/controllers
So far, I can access mysite.com/user/profile for example, and it calls Profile controller in User module correctly.
Now, I want to add a controller with name ‘User’ on frontend, for example I want to access mysite.com/user/view, which I mean to call actionView in /frontend/controllers/UserController.php instead of calling User module. Currently it calls the User module and return an error, Unable to resolve the request “user/view” (Error 404).
My question: How to ask Yii to prioritize to find controller first, then if it’s not found, it should look for it in the module?
My configs:
/frontend/config/main.php:
return CMap::mergeArray(
require(__DIR__ . '/../../common/config/main.php'),
array(
'basePath' => 'frontend',
...
'import' => array(
'application.components.*',
'application.controllers.*',
'application.models.*',
),
...
'components' => array(
'urlManager' => array(
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
)
),
),
/common/config/main.php:
return array(
'import' => array(
'common.components.*',
'common.models.*',
'common.modules.user.models.*',
'common.modules.user.components.*',
),
'modules'=>array(
'user'=>array(
'class' => 'common.modules.user.UserModule',
...
)
Bootstrap index.php file:
...
require_once('common' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Yii' . DIRECTORY_SEPARATOR . 'yii.php');
$config = require('frontend' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'main.php');
require_once('common' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'WebApplication.php');
$app = Yii::createApplication('WebApplication', $config);
$app->run();
Any help is appreciated, thanks in advance.