Answer the question
In order to leave comments, you need to log in
How to use Twig correctly?
Good evening! I am creating a not very big project, I decided to use OOP and twig. Only in order for the Front end and Back end to lie separately. The structure of the site is very simple, there is a left sidebar (dynamic) where the menu is displayed and the main content where the text is also dynamic. To display content, I created the articles class, which outputs articles.tpl to its template, and for the menu, the menu class, which outputs to the menu.tpl template, and this template is connected
<section class="content">
<div class="container">
<div class="row">
{% include "menu.tpl" %}
{% block content %}
{#тут контент#}
{% endblock %}
</div>
</div>
</section>
//Объект для вывода меню
$menu_object = new menu;
$menu=$menu_object->view()
echo $template->render(array('title'=>'Мой сайт', 'articles'=>$articles, 'menu_pages'=>$menu));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question