php - Rendering views in other places in Yii2 - no renderPartial? -


i need render partial view inside custom component file in yii2 , according yii docs can access view instance via this:

\yii::$app->view->renderfile('@app/views/site/license.php'); 

i went ahead , tried:

yii::$app->view->renderpartial('//my/view/'); 

...but got error trying access non-existent method.

i checked out view class , noticed doesn't have renderpartial , method of controller class instead.

i see has renderfile method , render method; of these should use?

the docs don't state render method includes layout method of same name controller class, i'm not sure; renderfile i'm not 100% sure if suitable either?

could explain method produce same results renderpartial produces?

you can call renderpartial yii::$app->controller->renderpartial('myview'); can see source code of yii\base\controller renderpartial calls view's render method can use yii::$app->view->render. there no difference between render , renderfile, because render internally calls renderfile. when use render can pass $view in several formats path alias, absolute path whithin application or whithin module , relative path. , renderfile can pass absolute file path or path alias.


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -