Hi there,
I'm using django-treemenus
I'm curious to see if there is a better way to write out my menu.html which is my menu template. For each level that I add to my menu I have to manually add a level to my menu template.
Here is my menu.html (menu template). It works, but could it be written more efficiently?
{% load tree_menu_tags %}
{% ifequal menu_type "horizontal" %}
<ul><!-- Root -->
{% for menu_item in menu.root_item.children %}
<!-- Level 1-->
{% if menu_item.has_children %}
<li><a href="{{ menu_item.url }}">{{ menu_item.caption }}</a>
<ul>
{% for child in menu_item.children %}
<!-- Level 2-->
{% if child.has_children %}
<li><a href="{{ child.url }}">{{ child.caption }}</a>
<ul>
{% for childchild in child.children %}
<!-- Level 3-->
{% if childchild.has_children %}
<li><a href="{{ childchild.url }}">{{ childchild.caption }}</a>
<ul>
{% for childchildchild in childchild.children %}
{% show_menu_item childchildchild %}
{% endfor %}
</ul>
</li>
{% else %}
<li><a href="{{ childchild.url }}">{{ childchild.caption }}</a></li>
{% endif %}
<!-- End Level 3 -->
{% endfor %}
</ul>
</li>
{% else %}
<li><a href="{{ child.url }}">{{ child.caption }}</a></li>
{% endif %}
<!-- End Level 2 -->
{% endfor %}
</ul>
</li>
{% else %}
<li><a href="{{ menu_item.url }}">{{ menu_item.caption }}</a></li>
{% endif %}
<!-- End Level 1 -->
{% endfor %}
</ul><!-- End Root -->
{% endifequal %}