首页 安企CMS模板标签手册 常用标签

导航列表标签

说明:用于获取页面导航列表

使用方法: {% navList 变量名称 %} 如将变量定义为navs {% navList navs with typeId=1 %}...{% endnavList %},也可以定义为其他变量名称,定义后,需要与下面的for循环使用的变量名称一致。

navList 标签只有一个参数

    导航类别 typeId 默认导航为 1,即 typeId=1 。如你自定义了其他导航,则 typeId=其他导航类别的ID。


navList,需要使用使用 endnavList 标签表示结束,中间使用for循环输出内容。

navs 是一个数组对象,因此需要使用 for 循环来输出


item 为for循环体内的变量,可用的字段有:

  • 导航标题 Title
  • 子标题 SubTitle
  • 导航描述 Description
  • 导航链接 Link
  • 是否当前链接 IsCurrent
  • 下级导航列表 NavList 下级导航内同样具有 item 相同的字段。


代码示例


{% navList navs with typeId=1 %}
<ul class="layui-nav layui-layout-left nav-list">
    {%- for item in navs %}
        <li class="layui-nav-item{% if item.IsCurrent %} layui-this{% endif %}">
            <a href="{{ item.Link }}">{{item.Title}}</a>
            {%- if item.NavList %}
            <dl class="layui-nav-child">
                {%- for inner in item.NavList %}
                    <dd class="{% if inner.IsCurrent %} layui-this{% endif %}">
                        <a href="{{ inner.Link }}">{{inner.Title}}</a>
                    </dd>
                {% endfor %}
            </dl>
            {% endif %}
        </li>
    {% endfor %}
</ul>
{% endnavList %}