Yii2 Advanced Template: Add Offline Web Pages

I added help.php to backend / views / site and declare a function under SiteController.php to find out the link

public function behaviors()
{
    return [
        'access' => [
            'class' => AccessControl::className(),
            'rules' => [
                [
                    'actions' => ['login', 'error'],
                    'allow' => true,
                ],
                [
                    'actions' => ['logout', 'index'],
                    'allow' => true,
                    'roles' => ['@'],
                ],
            ],
        ],
        'verbs' => [
            'class' => VerbFilter::className(),
            'actions' => [
                'logout' => ['post'],
            ],
        ],
    ];
}

public function actionHelp()
{
    return $this->render('help');
}

The link is now available, but it gives me the Forbidden error (# 403), and it says: "You are not allowed to perform this action."

Now I would like to ask if I can browse the web pages that I created. Thanks in advance.

+4
source share
1 answer

The problem is with the filter AccessControl.

You can add an action helpto the list of valid actions, for example:

[
    'actions' => ['login', 'error', 'help'],
    'allow' => true,
],

You can read more and check how the access rules in the section apply.

+2
source

All Articles