0

I use dektrium yii2-user in advanced template. I want to add new action in SettingsController.

What I've done:

Override SettingsController. Created /frontend/user/SettingsController.php

namespace frontend\controllers\user;

use dektrium\user\controllers\SettingsController as BaseSettingsController;

class SettingsController extends BaseSettingsController
{

    public function actionMyview()
    {
        $this->render('myview');
    }
}

Created new view /frontend/views/user/settings/view/myview.php And changed /common/main.php in components section

    'view' => [
        'theme' => [
            'pathMap' => [
                '@dektrium/user/views' => '@frontend/views/user'
            ],
        ],
    ],

But it doesn't work. When I go to mysite.com/user/settings/myview I see blank page without errors. Also I don't know how to override behaviours, so I added access rule for myview directly in /vendor/dektrium/yii2-user/controllers/SettingsController.php

How can I do that things right? Thanks.

Alex Pavlov
  • 571
  • 1
  • 7
  • 24

1 Answers1

1

Add this:

'user' => [
    'class' => 'dektrium\user\Module',
    //...
    'controllerMap' => [
        'settings' => [
            'class' => 'frontend\controllers\user\SettingsController',
            'layout' => '@app/views/layouts/main'
        ]
    ]
]

I got it! you forgot this is return

public function actionMyview()
{
    return $this->render('myview');
}
Vitaly
  • 1,261
  • 2
  • 10
  • 20