H
H
HellWalk2017-07-14 14:16:27
Yii
HellWalk, 2017-07-14 14:16:27

How does Yii2 pull up views?

I did not work with Yii2, I had little experience with Laravel.
I was given a large project on Yii2 at work, I can’t understand how views are pulled up in it.
The calls go like this:

$this->render('/admin/expert/index'
$this->render('message'
$this->render('index'
$this->render('/site/cabinet/cabinet_user_info'
$this-> render('/register/remember_password_success'

At the same time, the project does not have a common views folder, but there are themes with two templates inside, and modules with three modules, each of which has its own views.
I can't figure out how controllers understand which (and where) to pull the view from? Tell.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-07-14
@webinar

There is a views folder, it contains all the views.
If just the view name is specified, then it searches in 'views/controller_name/requested_view_name.php'
If there is a slash in front, then the full path from the views folder
Accordingly, specifically according to your examples:

$this->render('/admin/expert/index');  // views/admin/expert/index.php
$this->render('message'); // views/имяКонтролера/message.php
$this->render('index'); // views/имяКонтролера/index.php
$this->render('/site/cabinet/cabinet_user_info'); // views/cabinet/cabinet_user_info.php
$this->render('/register/remember_password_success'); // views/register/remember_password_success.php

The name of the controller is the name of its class without Controller and with a small letter, that is, for SiteController - the views / site folder for MyMegaSuperController - views / my-mega-super
Unless, of course, nothing is redefined in the project.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question