Nested Controllers issue

I’m using nested controllers like:


/protected/controllers/tools/calculators/IndexController.php

/protected/controllers/tools/calculators/IraController.php

/protected/controllers/tools/calculators/SavingaccountController.php

I can then access them by:


?r=tools/calculators/index

?r=tools/calculators/ira

?r=tools/calculators/savingaccount

etc.

How do I tell Yii, that if I ommit the final controller, that by default I want ‘index’? In other words, I want to do


?r=tools/calculators/

I am using in my config:


'defaultController' => 'index',

It works for top level controllers but not nested ones.

I think i got it!




            '<controller1:\w+>/<controller2:\w+>/<controller3:\w+>/' => array('<controller1>/<controller2>/<controller3>/index', 'caseSensitive'=>false),

            '<controller1:\w+>/<controller2:\w+>/<action:\w+>.php' => array('<controller1>/<controller2>/index/<action>', 'caseSensitive'=>false),

            '<controller1:\w+>/<controller2:\w+>/' => array('<controller1>/<controller2>/index', 'caseSensitive'=>false),

            '<controller:\w+>/<action:\w+>.php' => array('<controller>/index/<action>', 'caseSensitive'=>false),

            '<controller:\w+>' => array('<controller>/index', 'caseSensitive'=>false),

            '<action:\w+>.php' => array('index/<action>', 'caseSensitive'=>false),



Yii doesn’t support nested controllers.

You should, instead, use modules.

What do you mean? I have them nested and working fine.

http://www.yiiframework.com/doc/guide/1.1/en/basics.controller

You’ll have issues with your setup, use modules instead, their usage is for your purpose.

Also, learn to format your url rules, the .html in the rule shouldn’t be there, see : http://www.yiiframework.com/doc/api/1.1/CUrlManager#urlSuffix-detail and http://www.yiiframework.com/doc/api/1.1/CUrlRule#urlSuffix-detail