說明:用于獲取頁面導航列表
使用方法: {% navList 變量名稱 %}
如將變量定義為navs {% navList navs %}...{% endnavList %}
,也可以定義為其他變量名稱,定義后,需要與下面的for循環(huán)使用的變量名稱一致。
typeId
typeId
為后臺的導航類別ID,默認 typeId=1
,如果后臺設(shè)置了多個導航類別,可以通過typeId
來指定調(diào)用。siteId
siteId
一般不需要填寫,如果你使用后臺的多站點管理創(chuàng)建了多個站點,并且想調(diào)用其他站點的數(shù)據(jù),則可以通過指定 siteId
來實現(xiàn)調(diào)用指定站點的數(shù)據(jù)。navList 需要使用使用 endnavList 標簽表示結(jié)束,中間使用for循環(huán)輸出內(nèi)容。
navs 是一個數(shù)組對象,因此需要使用 for
循環(huán)來輸出
Title
SubTitle
Description
Link
PageId
如果這個導航菜單是選擇了分類的話,則存在IsCurrent
NavList
下級導航內(nèi)同樣具有 item 相同的字段。{% navList navs %}
<ul>
{%- for item in navs %}
<li class="{% if item.IsCurrent %}active{% endif %}">
<a href="{{ item.Link }}">{{item.Title}}</a>
{%- if item.NavList %}
<dl>
{%- for inner in item.NavList %}
<dd class="{% if inner.IsCurrent %}active{% endif %}">
<a href="{{ inner.Link }}">{{inner.Title}}</a>
</dd>
{% endfor %}
</dl>
{% endif %}
</li>
{% endfor %}
</ul>
{% endnavList %}
調(diào)用代碼示例,該調(diào)用需要在后臺已經(jīng)設(shè)置好二級導航的基礎(chǔ)上(代碼不包含css樣式控制)
<ul>
{% navList navList with typeId=1 %}
{%- for item in navList %}
<li>
<a href="{{ item.Link }}">{{item.Title}}</a>
{%- if item.NavList %}
<ul class="nav-menu-child">
{%- for inner in item.NavList %}
<li>
<a href="{{ inner.Link }}">{{inner.Title}}</a>
{% archiveList products with type="list" categoryId=inner.PageId limit="8" %}
{% if products %}
<ul class="nav-menu-child-child">
{% for item in products %}
<li><a href="{{item.Link}}">{{item.Title}}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endarchiveList %}
</li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
{% endnavList %}
</ul>
調(diào)用代碼示例,該調(diào)用需要在后臺已經(jīng)設(shè)置好二級導航的基礎(chǔ)上(代碼不包含css樣式控制)
<ul>
{% navList navList with typeId=1 %}
{%- for item in navList %}
<li>
<a href="{{ item.Link }}">{{item.Title}}</a>
{%- if item.NavList %}
<ul class="nav-menu-child">
{%- for inner in item.NavList %}
<li>
<a href="{{ inner.Link }}">{{inner.Title}}</a>
{% if inner.PageId > 0 %}
{% categoryList categories with parentId=inner.PageId %}
{% if categories %}
<ul>
{% for item in categories %}
<li>
<a href="{{ item.Link }}">{{item.Title}}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% endcategoryList %}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
{% endnavList %}
</ul>