2015-09-26 30 views
0
{% load i18n menu_tags cache %} 
{% for child in children %} 
<li class="{% if child.ancestor %}ancestor{% endif %} 
    {% if child.selected %} active{% endif %} 
    {% if child.chil`enter code here`dren %} dropdown{% endif %}"> 
    {% if child.children %} 
     <a class="dropdown-toggle" data-toggle="dropdown" href="#"> 
      {{ child.get_menu_title }} <span class="caret"></span> 
     </a> 
     <ul class="dropdown-menu"> 
      {% show_menu from_level to_level extra_inactive extra_active template "" "" child %} 
     </ul> 
    {% else %} 
     <a href="{{ child.get_absolute_url }}"><span>{{ child.get_menu_title }}</span></a> 
    {% endif %} 
</li> 

{% if class and forloop.last and not forloop.parentloop %}{% endif %} 
{% endfor %} 

這是djagocms項目中的menu.html代碼。如何在djangoCMS中顯示多級菜單欄

任何人都可以幫助我,我們如何可以在djangocms中顯示多級菜單欄。像:

---------- 
> main menu 
> --sub menu 
> --sub menu 
> ----sub menu 
> ----sub menu 

回答

1

我有一個多級菜單,我包括在我的基本模板中是這樣的;

 <ul class="dropdown"> 
      {% show_menu 1 100 100 100 "partials/navigation.html" %} 
     </ul> 

該自定義模板看起來像這樣;

{% load cms_tags menu_tags cache cms_page %} 

{% for child in children %} 
    <li> 
     <a href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">{{ child.get_menu_title }}</a> 
     {% if child.children and child.level <= 4 %} 
      <ul> 
      {% show_menu from_level to_level extra_inactive extra_active template '' '' child %} 
      </ul> 
     {% endif %} 
    </li> 
{% endfor %} 

這使得出多級菜單,顯示一個頁面的所有兒童作爲一個新的列表。