Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of "Yii::app()->controller->renderPartial" in Yii2?

Tags:

php

yii2

What is the equivalent of

Yii::app()->controller->renderPartial

in Yii2 ??

like image 373
Abhi Avatar asked Jan 05 '15 14:01

Abhi


2 Answers

In view files, $this refers to yii\web\View object so simply call:

$this->render('partials/_profile', ['name'=>'value']);

and it will work.

Or pass and absolute path to renderFile() to skip the call to findViewfile():

$this->renderFile(dirname(_FILE__) . '/partials/_profile.php', ['name'=>'value']);
like image 174
user1502826 Avatar answered Nov 01 '22 13:11

user1502826


in yii2

Yii::$app->controller->renderPartial('myview');
like image 14
Mahmut Aydın Avatar answered Nov 01 '22 14:11

Mahmut Aydın