R
R
romany42014-09-26 13:51:52
Yii
romany4, 2014-09-26 13:51:52

How to organize page templates in yii2?

How to organize page templates in yii2?
Let me explain
, for example, I want to organize
- the main page
template - the category page template
- the rest of the pages
template By templates I mean the outer wrapper

<html>
<head>...</head>
<body>...</body>
</html>

Different templates have their own base html code. (for example - the general structure of the content output, certain included files, etc.) The
question is how to correctly set the match by url?
For example
'/' => 'main.layout',
'/cat/' => 'cat.layout',
'default' => 'other.layout' //(в данном случае default - это не url, а некое зарезервированное слово)

Another question - if it is in the framework or does it need to be finalized by yourself?
ps - for comparison (if anyone is in the subject) - I need something similar to page templates in Bitrix - /bitrix/templates/

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2014-09-26
Protko @Fesor

Take twig and don't be bullshit.

P
phpnt, 2015-03-06
@phpnt

Creating a simple Yii2 "Hello WORLD!!!" application

E
Eureka, 2015-10-07
@Eureka

You can add a line to the beginning of the actionIndex() function of the SiteController object $this->layout = '@app/views/layouts/index.php';and now layout index.php will be used for the main one. Similar logic can be applied in other cases (if I understand your question correctly).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question