How to create static pages using action() method?


(Ganesh Patel) #1

How to create static pages using action() method ?


(Alexander Makarov) #2

https://www.yiiframework.com/doc/api/2.0/yii-web-viewaction


(Ganesh Patel) #3

Example With Site Controller

1. Update actions Method

 public function actions() {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
            'captcha' => [
                'class' => 'yii\captcha\CaptchaAction',
                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
            ],
            'pages' => [
                'class' => 'yii\web\ViewAction',
            ],
        ];
    }

2. Create Directory “pages” under views/site

image

3. update routing rule

'<view>' => '/site/pages'

4. Create Static view under views/site