Templates 如何从Zotonic模板访问菜单模型?
我想写我自己风格的菜单,但我更喜欢在模板中完成,而不是制作我自己的菜单 我基本上希望能够做到以下几点:Templates 如何从Zotonic模板访问菜单模型?,templates,zotonic,Templates,Zotonic,我想写我自己风格的菜单,但我更喜欢在模板中完成,而不是制作我自己的菜单 我基本上希望能够做到以下几点: {% if m.menu %} <ul> {% for top_level_id in m.menu %} {% with m.rsc[top_level_id] as top_level %} <li><a href="{{ top_level.page_url }}">{{ top_level.title }}</a&g
{% if m.menu %}
<ul>
{% for top_level_id in m.menu %}
{% with m.rsc[top_level_id] as top_level %}
<li><a href="{{ top_level.page_url }}">{{ top_level.title }}</a>
{% if top_level.menu %}
<ul>
{% for mid_level_id in top_level.menu %}
{% with m.rsc[mid_level_id] as mid_level %}
<li><a href="{{ midlevel.page_url }}">{{ mid_level.title }}</a></li>
{% endwith %}
{% endfor %}
</ul>
{% endif %}
</li>
{% endwith %}
{% endfor %}
</ul>
{% endif %}
{%if m.menu%}
{m.menu%中的顶级\u id为%s}
{%以m.rsc[top_level_id]作为top_level%}
-
{%if top_level.menu%}
{顶级菜单%中的中级菜单id为%
{%m.rsc[mid_level_id]作为mid_level%}
{%endwith%}
{%endfor%}
{%endif%}
{%endwith%}
{%endfor%}
{%endif%}
如何从Zotonic模板访问菜单模型?Zotonic(即将推出的)0.5版本和提示使用模板显示菜单。检查mod\u menu/templates/\u menu.tpl
此模板由菜单scomp调用。添加到我以前的答案中。标准的
\u菜单。tpl
接收包含所有菜单项的列表。此列表是完整菜单的深度优先树漫游的结果。每一份菜单都是一张记录
{MenuRscId, DepthOfMenu, NrInSubMenu, HasSubMenuFlag}
其中,顶级菜单的深度为1,菜单中的第一个菜单项的nr为1
当前用户不允许看到的所有菜单项都将被过滤掉
默认模板的代码:
<ul id="{{ id_prefix }}navigation" class="clearfix at-menu do_superfish">
{% for mid,depth,nr,has_sub in menu %}
{% if not mid %}{% if depth > 1 %}</ul></li>{% endif %}
{% else %}
{% if nr == 1 and not forloop.first %}<ul{% if mid|member:path %} class="onpath"{% endif %}>{% endif %}
<li id="{{ id_prefix }}nav-item-{{nr}}"
class="{% if is_first %}first {% endif %}{% if is_last %}last{% endif %}">
<a href="{{ m.rsc[mid].page_url }}"
class="{{ m.rsc[mid].name }}{% if mid == id %} current{% else %}{% if mid|member:path %} onpath{% endif %}{% endif %}">{{ m.rsc[mid].short_title|default:m.rsc[mid].title }}</a>
{% if not has_sub %}</li>{% endif %}
{% endif %}
{% endfor %}
{% if forloop.last %}{% include "_menu_extra.tpl" %}{% endif %}
</ul>
{%表示中间,深度,nr,在菜单%中有子项}
{%if-not-mid%}{%if-depth>1%}
{%endif%}
{%else%}
{%if nr==1且不是forloop.first%}{%endif%}
{%if没有_sub%} {%endif%}
{%endif%}
{%endfor%}
{%if-forloop.last%}{%include“\u menu\u extra.tpl”}{%endif%}