Answer the question
In order to leave comments, you need to log in
How to include php file in views in yii2?
Hello. My index.php, which is in views, is already very crowded due to a lot of if and else. Tell me how in yii2 you can divide the view file into several files, that is: in index.php from views / model / make several include, and in these inserted files already prescribe the conditions? The problem is that I don't know how to link to the file I want to include. I created it and it's located at views/model/ . By default, in yii2 all links lead to the web folder. How to get into views?
PS Will the variable with the array that I pass from the controller propagate to the embedded file?
Answer the question
In order to leave comments, you need to log in
View has a render method , i.e. you can do it right in your view:
$this->render('@app/views/site/index', [
'var' => 'val',
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question