Last active
April 18, 2016 11:21
-
-
Save mikemadisonweb/3b6e65bcbbf5f01365bb to your computer and use it in GitHub Desktop.
Twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ 'now'|date("Y") }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For $_POST variables use this : | |
{{ app.request.parameter.get("page") }} | |
For $_GET variables use this : | |
{{ app.request.query.get("page") }} | |
For $_COOKIE variables use this : | |
{{ app.request.cookies.get("page") }} | |
For $_SESSION variables use this : | |
{{ app.request.session.get("page") }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set route_params = app.request.attributes.get('_route_params') %} | |
{# merge the query string params if you want to keep them when switching the locale #} | |
{% set route_params = route_params|merge(app.request.query.all) %} | |
{# merge the additional params you want to change #} | |
{% set route_params = route_params|merge({'_locale': 'fr'}) %} | |
{{ path(app.request.attributes.get('_route'), route_params) }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% import _self as macros %} | |
{% block content %} | |
<ul class="mt-doc-list"> | |
{% for rubric in rubrics %} | |
{{ macros.recursiveRubrics(rubric) }} | |
{% endfor %} | |
</ul> | |
{% endblock content %} | |
{% macro recursiveRubrics(rubric) %} | |
<li> | |
<a href="{{ rubric.path }}">{{ rubric.title }}</a> | |
{% if rubric.children|length %} | |
<ul> | |
{% for child in rubric.children %} | |
{{ _self.recursiveRubrics(child) }} | |
{% endfor %} | |
</ul> | |
{% endif %} | |
</li> | |
{% endmacro %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment