Skip to content

Commit 8933aba

Browse files
committed
support infinite number of submenus
1 parent 6862c39 commit 8933aba

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<ul class="dropdown-menu">
2+
{% for item in items %}
3+
{% if item.visible %}
4+
<li class="{% if item.selected %} active{% endif %}{% if item.children %} dropdown-submenu{% endif %}">
5+
<a href="{{ item.url }}">{{ item.title }}</a>
6+
{% if item.children %}
7+
{% with items=item.children template_name='bootstrap-navbar-submenu.html' %}
8+
{% include template_name %}
9+
{% endwith %}
10+
{% endif %}
11+
</li>
12+
{% endif %}
13+
{% endfor %}
14+
</ul>

menu/templates/bootstrap-navbar.html

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
{% for item in menu %}
2-
{% if item.separator %}<li class="divider-vertical"></li>{% endif %}
3-
<li class="{% if item.selected %} active{% endif %}{% if item.children %} dropdown{% endif %}" id="top-menu-{{ item.slug }}">
4-
{% if item.children %}
5-
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown">{% if item.icon %}<i class="icon-{{ item.icon }} icon-white"></i>&nbsp;{% endif %}{{ item.title }}&nbsp;<b class="caret"></b></a>
6-
<ul class="dropdown-menu">
7-
{% for child in item.children %}<li{% if child.selected %} class="active"{% endif %}><a href="{{ child.url }}">{{ child.title }}</a></li>{% endfor %}
8-
</ul>
9-
{% else %}
10-
<a href="{{ item.url }}">{% if item.icon %}<i class="icon-{{ item.icon }} icon-white"></i>&nbsp;{% endif %}{{ item.title }}</a>
2+
{% if item.visible %}
3+
{% if item.separator %}
4+
<li class="divider-vertical"></li>
5+
{% endif %}
6+
7+
<li class="{% if item.selected %} active{% endif %}{% if item.children %} dropdown{% endif %}" id="top-menu-{{ item.slug }}">
8+
<a href="{{ item.url }}"{% if item.children %} class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"{% endif %}>
9+
{% if item.icon %}
10+
<i class="icon-{{ item.icon }} icon-white"></i>&nbsp;
11+
{% endif %}
12+
<span>{{ item.title }}</span>
13+
{% if item.children %}
14+
&nbsp;<b class="caret"></b>
15+
{% endif %}
16+
</a>
17+
{% if item.children %}
18+
{% include 'bootstrap-navbar-submenu.html' with items=item.children %}
19+
{% endif %}
20+
</li>
1121
{% endif %}
12-
</li>
1322
{% endfor %}

0 commit comments

Comments
 (0)