Answer the question
In order to leave comments, you need to log in
Twig how to make different templates for guest and user?
Faced the following problem, I have a task to make a page that should be inserted into a different layout for the guest and for the user.
I.e. There is, when a guest visits the site, he sees the pages in a certain way, when he logs in, he gets into his personal account and these same pages (only in a certain case, for example, statistical pages) he must see through his personal account.
It looks like this (main template):
...
{% block pageTitleContainer %}{% endblock %}
{% block slider %}{% endblock %}
<!-- MAIN CONTENT -->
<div id="outermain">
<div class="container">
<section id="maincontent" class="twelve columns">
{% block content %}{% endblock %}
<div class="clear"></div><!-- clear float -->
</section>
</div>
</div>
...
{% extends "@app/themes/basic/layouts/main.twig" %}
{% block title %} Личный Бэк-офис {% endblock %}
{% block content %}
....
{% block office_content %}
-----
{% endblock office_content %}
...
{% endblock content %}
Answer the question
In order to leave comments, you need to log in
Well, pass the session to the template or some variable that says that you need to display this or that block.
twig.sensiolabs.org/doc/tags/if.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question