【问题标题】:How do you get third-level menu items in Zotonic?如何在 Zotonic 中获得三级菜单项?
【发布时间】:2010-10-20 23:00:20
【问题描述】:

我想在 Zotonic 中显示三级菜单项。

例如,如果我有如下层次结构中的页面:

  • 关于我们
    • 职业
      • 为什么在这里工作?

我希望能够在下拉菜单中访问为什么在这里工作?

如何在 Zotonic 中获得三级菜单项?

【问题讨论】:

    标签: menubar zotonic


    【解决方案1】:

    我使用了页面连接和修改后的菜单模板。这需要 Zotonic 0.5.0 或更高版本。

    1. 创建一个名为Menu谓词,从texttext
    2. 编辑/modules/mod_menu/templates/_menu.tpl:

      翻开原菜单模板:

      {% if menu %}
          <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>
      {% endif %}
      

      进入三级菜单版:

      {% if menu %}
          <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 depth == 2 %}
                      {% for submenu in m.rsc[mid].menu %}
                          {% if forloop.first %}<ul>{% endif %}
                          <li id="{{ id_prefix }}nav-item-{{nr}}" class="{% if is_first %}first {% endif %}{% if is_last %}last{% endif %}">
                              <a href="{{ m.rsc[submenu].page_url }}"
                                 class="{{ m.rsc[submenu].name }}{% if submenu == id %} current{% else %}{% if submenu|member:path %} onpath{% endif %}{% endif %}">{{ m.rsc[submenu].short_title|default:m.rsc[submenu].title }}</a></li>
                          {% if forloop.last %}</ul>{% endif %}
                      {% endfor %}
                  {% endif %}
                  {% if not has_sub %}</li>{% endif %}
              {% endif %}
          {% endfor %}
          {% if forloop.last %}{% include "_menu_extra.tpl" %}{% endif %}
          </ul>
      {% endif %}
      

      通过为二级项的菜单页面连接添加特殊情况:

                {% if depth == 2 %}
                    {% for submenu in m.rsc[mid].menu %}
                        {% if forloop.first %}<ul>{% endif %}
                        <li id="{{ id_prefix }}nav-item-{{nr}}" class="{% if is_first %}first {% endif %}{% if is_last %}last{% endif %}">
                            <a href="{{ m.rsc[submenu].page_url }}"
                               class="{{ m.rsc[submenu].name }}{% if submenu == id %} current{% else %}{% if submenu|member:path %} onpath{% endif %}{% endif %}">{{ m.rsc[submenu].short_title|default:m.rsc[submenu].title }}</a></li>
                        {% if forloop.last %}</ul>{% endif %}
                    {% endfor %}
                {% endif %}
      
    3. Page Connections中添加*Menu*s到每个需要菜单中三级项的页面

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多