Calle
Calle

Reputation: 1800

Yii UrlManager route to own controller instead of module

I have just gotten started with the Yii framework, trying to create a simple application. I have added the yii-user-management module (YUM) and have followed the short installation tutorial.

Following the tutorial, I created a RegistrationController that extends the YumRegistrationController - then tried loading it in the browser. However, regardless of how I change the config for UrlManager, I cannot get my own controller or view loaded (the view was copied to protected/views/registration.registration.php as instructed).

I am not the only one with the same problem - see here for example - but I cannot get any of the solutions working. Not even renaming the controller has worked, so I figure that there is something fundamentally wrong with my UrlManager settings.

'urlManager'=>array(
        'urlFormat'=>'path',
        'showScriptName'=>false,
        'caseSensitive'=>false,   
        'rules'=>array(
            '<controller:\w+>/<id:\d+>'=>'<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
        ),
    ),

The YumRegistrationController gets loaded every time, or I get a 404 error.

I have tried additional rules, like:

'registration' => 'application.controllers.Registration',

or (after renaming)

'registration' => '//MyRegistration/registration',

and even

'registration' => '//registration/registration/registration',

like in an article I read, but nothing worked.

Please help - I would really love to move on to creating an app instead of just working on the setup...

UPDATE: /registration/registration/registration works, it just shows the default view and loads the controller for YUM registration...

Yii version 1.1.10

Upvotes: 1

Views: 1461

Answers (1)

Shiv
Shiv

Reputation: 1267

I think , you have user component registered in your config main.php. So please share that. I can help.

. 'loginUrl' => array('/user/user/login'), may cause problem. no need to change urlManager.

         'user'=>array(
        'class'=>'application.components.WebUser',
          'allowAutoLogin'=>true,
          'loginUrl' => array('/user/login'),
          ),

Upvotes: 1

Related Questions