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

发布于 2024-09-29 00:11:56 字数 216 浏览 0 评论 0 原文

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

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

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

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

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

I would like to display third-level menu items in Zotonic.

For example if I have pages in a hierarchy like the following:

  • About Us
    • Careers
      • Why work here?

I want the Why work here? to be accessible in the drop-down menus.

How do you get third-level menu items in Zotonic?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘦怹 2024-10-06 00:11:56

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

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

    将原来的菜单模板变成:

    {% if 菜单 %}
        
      {% 菜单中的中、深度、nr、has_sub %} {% 如果不是中%} {%如果深度> 1 %}
    {% endif %} {% 别的 %} {% if nr == 1 并且不是 forloop.first %}{% endif %}
  3. {{ m.rsc[mid].short_title|默认:m.rsc[mid].title }} {% if not has_sub %}
  4. {% endif %} {% 结束 %} {% 结束 %} {% if forloop.last %}{% include "_menu_extra.tpl" %}{% endif %} {% 结束 %}

    进入三级菜单版本:

    {% if 菜单 %}
        
      {% 菜单中的中、深度、nr、has_sub %} {% 如果不是中%} {%如果深度> 1 %}
    {% endif %} {% 别的 %} {% if nr == 1 并且不是 forloop.first %}{% endif %}
  5. {{ m.rsc[mid].short_title|默认:m.rsc[mid].title }} {% 如果深度 == 2 %} {% m.rsc[mid].menu 中的子菜单 %} {% if forloop.first %}
      {% endif %}
    • {{ m.rsc[submenu].short_title|default:m.rsc[submenu].title }}
    • ; {% if forloop.last %}
    {% endif %} {% 结束 %} {% 结束 %} {% if not has_sub %}
  6. {% endif %} {% 结束 %} {% 结束 %} {% if forloop.last %}{% include "_menu_extra.tpl" %}{% endif %} {% 结束 %}

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

     {% 如果深度 == 2 %}
                  {% m.rsc[mid].menu 中的子菜单 %}
                      {% if forloop.first %}
      {% endif %}
    • {{ m.rsc[submenu].short_title|default:m.rsc[submenu].title }}
    • ; {% if forloop.last %}
    {% endif %} {% 结束 %} {% 结束 %}
  7. ,向每个需要菜单中第三级项目的页面添加*菜单*

I used Page Connections and a modified menu template. This requires Zotonic 0.5.0 or later.

  1. Create a Predicate called Menu from text to text
  2. Edit /modules/mod_menu/templates/_menu.tpl:

    Turn the original menu template:

    {% 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 %}
    

    Into the third-level menu version:

    {% 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 %}
    

    By adding a special case for the menu page connections of second-level items:

              {% 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. In Page Connections add *Menu*s to each page that needs third-level items in the menu

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文