高安全性的内容管理系统
一站式建站解决方案
高性能静态网站构建工具
精美的网站模板库
详细的模板开发指南
完整的API接口说明
直观的视频使用指南
常见问题解答集锦
最新产品动态与行业资讯
了解我们的故事
获取支持与合作
说明:用于获取文章、产品分类列表
使用方法:{% categoryList 变量名称 with moduleId="1|2|3" parentId="0" %} 如将变量定义为 categories {% categoryList categories with moduleId="1" parentId="0" %}...{% endcategoryList %}
{% categoryList 变量名称 with moduleId="1|2|3" parentId="0" %}
{% categoryList categories with moduleId="1" parentId="0" %}...{% endcategoryList %}
moduleId
moduleId="1"
parentId
parentId="parent"
all
all=true
limit
limit="10"
offset
,
limit="2,10"
siteId
如果想获取当前分类的下级分类,则不需要指定 parentId。如果想获取当前分类的兄弟分类,则指定 parentId="parent",仅当在文档列表的时候有效。
categories 是一个数组对象,因此需要使用 for 循环来输出
for
Id
Title
Link
Description
Content
ParentId
Logo
Thumb
Spacer
HasChildren
IsCurrent
ArchiveCount
{% categoryList categories with moduleId="1" parentId="0" %} <ul> {% for item in categories %} <li> {# 如需判断当前是否是循环中的第一条,可以这么写: #} {% if forloop.Counter == 1 %}这是第一条{% endif %} {# 比如需要给第一条添加额外class="active",可以这么写: #} <a class="{% if forloop.Counter == 1 %}active{% endif %}" href="{{item.Link}}">{{item.Title}}</a> <a href="{{ item.Link }}">{{item.Spacer|safe}}{{item.Title}}</a> <a href="{{ item.Link }}"> <span>当前第{{ forloop.Counter }}个,剩余{{ forloop.Revcounter}}ge</span> <span>分类ID:{{item.Id}}</span> <span>分类名称:{{item.Title}}</span> <span>分类链接:{{item.Link}}</span> <span>分类描述:{{item.Description}}</span> <span>分类内容:{{item.Content|safe}}</span> <span>上级分类ID:{{item.ParentId}}</span> <span>下级分类前缀:{{item.Spacer|safe}}</span> <span>是否有下级分类:{{item.HasChildren}}</span> </a> <div>缩略图大图:<img style="width: 200px" src="{{item.Logo}}" alt="{{item.Title}}" /></div> <div>缩略图:<img style="width: 200px" src="{{item.Thumb}}" alt="{{item.Title}}" /></div> </li> {% endfor %} </ul> {% endcategoryList %}
{% categoryList categories with moduleId="1" parentId="0" %} {#一级分类#} <ul> {% for item in categories %} <li> <a href="{{ item.Link }}">{{item.Title}}</a> <div> {% categoryList subCategories with parentId=item.Id %} {#二级分类#} <ul> {% for inner1 in subCategories %} <li> <a href="{{ inner1.Link }}">{{inner1.Title}}</a> <div> {% categoryList subCategories2 with parentId=inner1.Id %} {#三级分类#} <ul> {% for inner2 in subCategories2 %} <li> <a href="{{ inner2.Link }}">{{inner2.Title}}</a> </li> {% endfor %} </ul> {% endcategoryList %} </div> </li> {% endfor %} </ul> {% endcategoryList %} </div> </li> {% endfor %} </ul> {% endcategoryList %}
调用代码示例(代码不包含 css 样式控制)
{% categoryList categories with moduleId="1" parentId="0" %} <div> {% for item in categories %} <div> <h3><a href="{{ item.Link }}">{{item.Title}}</a></h3> <ul> {% archiveList archives with type="list" categoryId=item.Id limit="6" %} {% for archive in archives %} <li> <a href="{{archive.Link}}"> <h5>{{archive.Title}}</h5> <div>{{archive.Description}}</div> <div> <span>{{stampToDate(archive.CreatedTime, "2006-01-02")}}</span> <span>{{archive.Views}} 阅读</span> </div> </a> {% if archive.Thumb %} <a href="{{archive.Link}}"> <img alt="{{archive.Title}}" src="{{archive.Thumb}}"> </a> {% endif %} </li> {% empty %} <li> 该列表没有任何内容 </li> {% endfor %} {% endarchiveList %} </ul> </div> {% endfor %} </div> {% endcategoryList %}
<div> {% categoryList productCategories with moduleId="2" parentId="0" %} {% for item in productCategories %} <a href="{{item.Link}}">{{item.Title}}</a> <ul class="ind-pro-nav-ul"> {% if item.HasChildren %} {% categoryList subCategories with parentId=item.Id %} {% for inner in subCategories %} <li><a href="{{inner.Link}}" title="">{{inner.Title}}</a></li> {% endfor %} {% endcategoryList %} {% else %} {% archiveList products with type="list" categoryId=item.Id limit="8" %} {% for inner in products %} <li><a href="{{inner.Link}}" title="">{{inner.Title}}</a></li> {% endfor %} {% endarchiveList %} {% endif %} </ul> {% endfor %} {% endcategoryList %} </div>