如何用django-cms创建多个菜单 [英] How can you create multiple menus with django-cms
问题描述
[Logo] Link_A Link_B Link_C Link_D
...内容...
Link_E Link_F Link_G Link_H
在 {%show_menu%}
中使用烘焙,将显示所有注册的页面,链接A - H,不会允许我分开两个菜单。
如何创建两个单独的菜单?
取决于你想要做的事情,但是我有一个基本模板,顶部有一个导航菜单和一个网站地图子菜单
所以从导航开始;
{%show_menu 1 100 100 100partials / navigation.html%}
哪个使用模板;
{%load cms_tags menu_tags cache cms_page%}
{%for children in children %}
< li>
< a href ={{child.attr.redirect_url | default:child.get_absolute_url}}>
{{child.get_menu_title}}
< / a>
{%如果child.children和child.level< = 4%}
< ul>
{%show_menu from_level to_level extra_inactive extra_active template''''child%}
< / ul>
{%endif%}
< / li>
{%endfor%}
然后网站地图;
{%show_sub_menu 2 1 1partials / sitemap.html%}
和 sitemap.html
code> {%load cms_tags cms_page cache%}
{%if children%}
{%for children in children%}
< ul class =site-footer__column>
< li>
< h4>
< a href ={{child.attr.redirect_url | default:child.get_absolute_url}}>
{{child.get_menu_title}}
< / a>
< / h4>
< / li>
{%如果child.children%}
{child for child.children%}中的宝宝
< li class =footer_sub>
< a href ={{baby.attr.redirect_url | default:baby.get_absolute_url}}>
{{baby.get_menu_title}}
< / a>
< / li>
{%endfor%}
{%endif%}
< / ul>
{%endfor%}
{%endif%}
了解您可以提供菜单的选项(数字)可以让您显示网站的不同部分,但如果内置的菜单标签不符合您的需要,则可以编写自定义菜单标签。
标准菜单文档在这里; http://docs.django-cms.org/en/3.2 .2 / reference / navigation.html
这里是自定义菜单的文档; http://docs.django-cms.org/en/3.2 .2 / how_to / menus.html
I'm trying to have two separate menus in my django-cms app. One for the header and another with a different set of links for the footer:
[ Logo ] Link_A Link_B Link_C Link_D
... content ...
Link_E Link_F Link_G Link_H
Using baked in {% show_menu %}
, will show all of the pages registered, links A - H, and doesn't allow me to separate the two menus.
How can I create two separate menus?
Depends what you want to do really, but I've got a base template which has a navigation menu at the top and a sitemap submenu at the bottom.
So starting with the navigation;
{% show_menu 1 100 100 100 "partials/navigation.html" %}
Which uses the template;
{% 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 %}
Then the sitemap;
{% show_sub_menu 2 1 1 "partials/sitemap.html" %}
And sitemap.html
{% load cms_tags cms_page cache %}
{% if children %}
{% for child in children %}
<ul class="site-footer__column">
<li>
<h4>
<a href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">
{{ child.get_menu_title }}
</a>
</h4>
</li>
{% if child.children %}
{% for baby in child.children %}
<li class="footer_sub">
<a href="{{ baby.attr.redirect_url|default:baby.get_absolute_url }}">
{{ baby.get_menu_title }}
</a>
</li>
{% endfor %}
{% endif %}
</ul>
{% endfor %}
{% endif %}
Understanding the options (numbers) you can provide for a menu can enable you to display different parts of your site, but if the built in menu tags don't suit your needs, you could write a custom menu tag.
The standard menu docs are here; http://docs.django-cms.org/en/3.2.2/reference/navigation.html
And here are the docs for customising your menus; http://docs.django-cms.org/en/3.2.2/how_to/menus.html
这篇关于如何用django-cms创建多个菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!