Md Hasibur Rahaman
Md Hasibur Rahaman

Reputation: 1061

Yii routing issue when use module

I want to use my url manager something link that.For my blog details

http://example.com/yii-fremwork-install => it gose to blog controller details method

where "yii-fremwork-install" is slug of come from database.

and also wont a module for that i write my url manager something like that

'rules' => array(
                '<slug:.+>' => 'users/details',
                '<controller:\w+>/<id:\d+>' => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',

            ),

But when i rty to use my admin module

http://example.com/admin it go to user/details controller hoe to use this

Can some one give some idea to solve this issue.

Upvotes: 0

Views: 38

Answers (1)

benomite
benomite

Reputation: 868

The problem here is that <slug:.+> is used for every route.

You have to manually define all you controller in the rules array and define them first

Like this :

'rules' => array(
            '<controller:admin|default|item>' => '<controller>',
            '<controller:admin|default|item>/<id:\d+>' => '<controller>/view',
            '<controller:admin|default|item>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
            '<controller:admin|default|item>/<action:\w+>' => '<controller>/<action>',
            '<slug:.+>' => 'users/details',
        ),

Where your 3 other controllers are (as an example) AdminController, DefaultController and ItemController

Upvotes: 0

Related Questions