Include a view into another view in Yii

I have this View file that holds the contents of my page(lets call it body view)… but i have a header view and a footer view files(and their contents changes dynamically) and i want them to be included to my body view file that holds my the contents of my page.

is this possible? i also use layouts

and if its possible please give me some resources or idea how i can make it

NOTE: footer, header and body have separate controllers


you can include them like

$this->render('controlerName/viewName', array('data'=>$data));

You have to include it with the echo statement as below:

            echo $this->render('viewname', [
            'dataProvider' => $dataProvider,

Also look at the create view that already does this by including the _form view. Pasted below:

    <?= $this->render('_form', [
        'model' => $model,
    ]) ?>

Also I realized I responded to Yii 1.1 thread. This works in Yii 2 as well.