alockwood05
alockwood05

Reputation: 1076

Yii- How to add urlManager Rules within a module?

In Yii framework, the main config file defines components. one of which is urlManager:

 'urlManager'=>array(
                   'urlFormat'=>'path',
                   'showScriptName'=>false,
                   'rules'=>array('/'=>'site/homepage', //...

cool I like that, it works. Now I'm creating a module and that module I want to have a some routing rules that are specific to the module. I want /myModule/moduleController/action/:id to point to the action and pass an id along with it. but I don't want to have to touch any files outside of the module. I would think you could do this within the myModuleModule.php file.

I found a link http://www.yiiframework.com/forum/index.php/topic/25801-url-rules-in-module-definition/ about one way to do it but it seems hacky, and not ideal.

So my question: what is the best way to add urlManger rules within a module?

Upvotes: 4

Views: 8483

Answers (1)

Boaz Rymland
Boaz Rymland

Reputation: 1467

I think that this is a weak point in Yii - Url management from within the module is not nicely implemented (or designed). I haven't read this entire thread but it seems that this weak point hasn't escaped the attention of Yii's dev team and their thought/thinking about a solution. AFAIK, in the meantime, at the same breath when you load the module you'll need to plant the url manager rules in the config file.

Upvotes: 2

Related Questions