-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_menu_general.twig
62 lines (54 loc) · 2.79 KB
/
_menu_general.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{# Bootstrap Navigation#}
{%- macro display_sub_menu_item(item, loop) -%}
<a href="{{ item.link }}" class="dropdown-item index-{{ loop.index }}{% if loop.first %} first{% endif %}{% if loop.last %} last{% endif %}{% if item|current %} active{% endif %} {% if item.class is defined %}{{item.class}}{% endif %}">
{% if item.label is defined %}{{item.label}}{% else %} - {% endif %}
</a>
{%- endmacro -%}
{%- macro display_menu_item(item, loop) -%}
{%- from _self import display_menu_item -%}
{%- from _self import display_sub_menu_item %}
{% spaceless %}
{% if item.class is defined and "group-start" in item.class|split(" ") %}
<li class="nav-item nav-group {{ item.class|split(" ")|slice(1)|join(" ") }}"><ul>
{% elseif item.class is defined and "group-end" in item.class|split(" ") %}
</ul></li>
{% else %}
<li class="nav-item index-{{ loop.index }}{% if loop.first %} first{% endif %}{% if loop.last %} last{% endif %}{% if item.submenu is defined %} dropdown{% endif %}{% if item|current %} active{% endif %}{% if item.nav_class is defined %} {{item.nav_class}}{% endif %}">
<a href="{{ item.link }}" {% if item.title is defined %}title='{{ item.title|escape }}'{% endif -%}
class="nav-link{% if item.class is defined %} {{item.class}}{% endif %}{% if item.submenu is defined %} dropdown-toggle{% endif %}"
{%- if item.submenu is defined %} data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"{% endif %}>
{%- if item.label is defined %}{{item.label}}{% else %} - {% endif -%}
</a>
{%- if item.submenu is defined %}
<div class="dropdown-menu">
{% for submenu in item.submenu %}
{{ display_sub_menu_item(submenu, loop) }}
{% endfor %}
</div>
{%- endif -%}
</li>
{% endif %}
{% endspaceless -%}
{% endmacro -%}
{%- from _self import display_menu_item -%}
{#- Allow added menu items either before or after what was provided by the yml -#}
{%- set extra_menu_items_before = extra_menu_items_before | default([]) -%}
{%- set extra_menu_items_after = extra_menu_items_after | default([]) -%}
{%- if extra_menu_items_before is not empty -%}
{%- set menu = extra_menu_items_before|merge(menu) -%}
{%- endif -%}
{%- if extra_menu_items_after is not empty -%}
{%- set menu = menu|merge(extra_menu_items_after) -%}
{%- endif %}
{% block nav_main %}
<nav class="navbar navbar-dark">
{% block before_nav %}{% endblock %}
<ul class="nav navbar-nav">
{%- for item in menu -%}
{%- if item.label is defined -%}
{{ display_menu_item(item, loop) }}
{%- endif -%}
{%- endfor -%}
</ul>
</nav>
{% endblock %}