Moid Mohd Moid Mohd - 1 year ago 368
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?

Answer Source

Inside the relative action

public function actionYourAction($id)

    $this->layout = 'yourNewLayout';

    return $this->render('yourView', [
        'model' =>$model,
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download