Files
myep-team/templates/_partials/_tabs.html.twig
T

21 lines
1.2 KiB
Twig

{#
Renders a KnpMenu as the back link and a row of tabs above the content, for the sections of one
record (AdminMenuBuilder::createTeamerMenu()). Dividers are skipped; the item marked `back` by
AbstractMenuBuilder::addBackItem() becomes the link above the tabs.
#}
{% block root %}
{% set back = item.children|filter(child => child.extras.back is defined)|first %}
{% if back %}
{{ include('_partials/_back_link.html.twig', { 'url': back.uri, 'label': back.label }) }}
{% endif %}
<nav aria-label="Bereiche" class="tabs mb-8">
{% for child in item.children|filter(child => child.displayed and child.extras.divider is not defined and child.extras.back is not defined) %}
{# by route name: the items carry the return url, which the matcher would compare as well #}
{% set current = child.extras.routes|default([])|filter(r => r.route is defined and r.route == app.request.attributes.get('_route'))|length > 0 %}
<a href="{{ child.uri }}"
class="{{ html_classes('tab', { 'tab--current': current }) }}"
{% if current %}aria-current="page"{% endif %}>{{ child.label|raw }}</a>
{% endfor %}
</nav>
{% endblock %}