What is the equivalent of
Yii::app()->controller->renderPartial
in Yii2 ??
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']);
in yii2
Yii::$app->controller->renderPartial('myview');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With