说明:用于获取文章、产品分类列表
使用方法:{% categoryList 变量名称 with moduleId="1|2" parentId="0" %}
如将变量定义为 categories {% categoryList categories with moduleId="1" parentId="0" %}...{% endcategoryList %}
moduleId
moduleId
可以获取指定文档模型的分类列表如 moduleId="1"
获取文章模型的分类列表。parentId
parentId
表示上级分类,可以获取指定上级分类下的子分类,parentId="0"的时候,获取顶级分类。放要获取顶级分类的时候,必须指定模型ID moduleId
如果想获取当前分类的下级分类,则不需要指定 parentId
。如果想获取当前分类的兄弟分类,则指定 parentId="parent"
,仅当在文档列表的时候有效。
categories 是一个数组对象,因此需要使用 for
循环来输出
Id
Title
Link
Description
Content
ParentId
Logo
Thumb
Spacer
HasChildren
IsCurrent
{% categoryList categories with moduleId="1" parentId="0" %}
<ul>
{% for item in categories %}
<li>
<a href="{{ item.Link }}">{{item.Spacer|safe}}{{item.Title}}</a>
<a href="{{ item.Link }}">
<span>当前第{{ forloop.Counter }}个,剩余{{ forloop.Revcounter}}个</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 class="sub-categories">
{% categoryList subCategories with moduleId="1" parentId=item.Id %}
{#二级分类#}
<ul>
{% for inner1 in subCategories %}
<li>
<a href="{{ inner1.Link }}">{{inner1.Title}}</a>
<div class="sub-categories">
{% categoryList subCategories2 with moduleId="1" 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 %}