Is there a way to specify a default module e.g. site entry (/) goes to default/index/index, /foo goes to default/foo/index ?
Is there a way to specify a default module e.g. site entry (/) goes to default/index/index, /foo goes to default/foo/index ?
I have the same wish
No, but you can specify a default controller.
'defaultController' => 'module/controller',
Additionally you can use the controllerMap:
'defaultController' => 'content',
'controllerMap' => array(
...
'content' => 'application.modules.mymodule.controllers.ContentController',
...
),
But important:
If you set a defaultController/controllerMap in config/main.php that is part of a module,
the module property of the controller will not be set. So you can’t use ‘$this->module->…’ and the module will not be initialized.
You have to initialize the controllers module ‘manually’ and override the constructor
class MyModuleController
{
....
public function __construct($id, $module = null)
{
if (!isset($module))
$module = Yii::app()->getModule('mymodule');
parent::__construct($id, $module);
}
...
I use : ‘defaultController’=>‘user/auth’,
and it looks fine. I am not sure I know exactly where should I add your code
‘defaultController’=>‘user/auth’ is ok.
Sometimes using the additional controllerMap can be useful when you want to preconfigure a module controller (pageTitle,defaultAction,layout…) when it is used as ‘defaultController’ (see controllerMap ‘post’.
With the help of the controllerMap you can implement different initialization of the controller depending on the route:
created as ‘defaultController’ or by calling the full route (modulename/controllerid).
But you don’t need this for your purpose.