Moid Mohd Moid Mohd - 4 months ago 49x
PHP Question

Change layout file within a view in Yii2

I am doing a small project using Yii2.

Suppose I have same layout (header, footer) in a view (eg

) except a
in this view. I want a different or no header / footer in this file. What can I do the remove the header / footer only from this view file.

All I could get to change layout in different views. Is it possible to change layout in a single file of a view?


Inside the relative action

public function actionYourAction($id)

    $this->layout = 'yourNewLayout';

    return $this->render('yourView', [
        'model' =>$model,