分类列表
<!--{iCMS:category:list
  loop  = "true"
  row   = "10"
  cid   = "1"
  cid  != "1"
  cache = "true"
  time  = ""
  appid = ""
  cids  = ""  
  pids  = ""
  stype = ""
  as    = ""
  start = "0"
  step  = ""
  max   = ""
}-->
<!--{$category_list|print_r}-->
<!--{/iCMS}-->
使用范围
- 所有模板
 
属性介绍
| 属性 | 可选值 | 说明 | 
|---|---|---|
| loop | true | 循环标记 | 
| row | 10 | 返回行数 | 
| cid | 1|1,2,3 | 栏目ID,多项请用,隔开 | 
| cid! | 1|1,2,3 | 排除的栏目ID,多项请用,隔开 | 
| pids | 属性值|1,2,3 | 属性值,多项请用,隔开 | 
| cache | true | 启用缓存 | 
| time | 3600 | 缓存时间 | 
| appid | 2,3,4 | 应用ID | 
| mode | 2,3,4 | 应用ID | 
| stype | top,sub,self,suball | top:顶级栏目  sub:子级栏目 self:同级栏目 suball:所有子级栏目  | 
| as | 无 | 变量别名 | 
| start | 0 | 开始索引号 | 
| step | 1 | 步进值 | 
| max | 无 | 最大索引值 | 
调用方式
* <!--{$category_list.total}-->    总条数
* <!--{$category_list.prev}-->     上一条行号 (从1开始)
* <!--{$category_list.next}-->     下一条行号 (从1开始)
* <!--{$category_list.rownum}-->   行号 (从1开始)
* <!--{$category_list.index}-->    索引号 (从0开始)
* <!--{$category_list.first}-->    第一条为true 否则flase
* <!--{$category_list.last}-->     最后一条为true 否则flase
<!--{$category_list.name}-->         分类名称
<!--{$category_list.title}-->        分类SEO标题
<!--{$category_list.url}-->          分类网址
<!--{$category_list.description}-->  分类简介
<!--{$category_list|print_r}-->      查看所有内部变量
- page = "true" 时 可调用分页标签
 
<!--{$iCMS.PAGE.NAV}-->
- sub="all" 时 可获取所有子分类
 
常用示例
- 获取 10个顶级分类
 
<!--{iCMS:category:list loop="true" stype="top" row="10"}-->
 <a href="<!--{$category_list.url}-->"><!--{$category_list.name}--></a>
<!--{/iCMS}-->
- 获取 10个分类
 
<!--{iCMS:category:list loop="true" row="10"}-->
 <a href="<!--{$category_list.url}-->"><!--{$category_list.name}--></a>
<!--{/iCMS}-->
- 获取 栏目ID [1] 下 10个子分类
 
<!--{iCMS:category:list loop="true" row="10" stype="sub" cid="1"}-->
  <a href="<!--{$category_list.url}-->"><!--{$category_list.name}--></a>
<!--{/iCMS}-->
- 获取 栏目ID [1] 下所有子分类(包含N级子分类)
 
<!--{iCMS:category:list loop="true" row="100" stype="suball" cid="1"}-->
  <a href="<!--{$category_list.url}-->"><!--{$category_list.name}--></a>
<!--{/iCMS}-->
- 获取 10个顶级分类下 10个子分类
 
<!--{iCMS:category:list loop="true" stype="top" row="10"}-->
  顶级分类:<a href="<!--{$category_list.url}-->"><!--{$category_list.name}--></a>
    <!--{iCMS:category:list loop="true" row="10" stype="sub" cid="$category_list.cid" as="subcate"}-->
    子分类:<a href="<!--{$subcate.url}-->"><!--{$subcate.name}--></a> 
    <!--{/iCMS}-->
<!--{/iCMS}-->
- 获取 10个顶级分类下所有子分类 10个子分类
 
<!--{iCMS:category:list loop="true" stype="top" row="10"}-->
  顶级分类:<a href="<!--{$category_list.url}-->"><!--{$category_list.name}--></a>
    <!--{iCMS:category:list loop="true" row="10" stype="sub" cid="$category_list.cid" as="subcate"}-->
    子分类:<a href="<!--{$subcate.url}-->"><!--{$subcate.name}--></a> 
    <!--{/iCMS}-->
<!--{/iCMS}-->
为什么子分类要用subcate调用
因为
<!--{iCMS:category:list}-->有两个嵌套循环了,
为了不让数据错乱内部的
<!--{iCMS:category:list}-->
必需使用
as别名
所以两个以上相同标签嵌套调用都必需使用
as别名
- 父级跟子级用同一个模板 怎么获取 
子栏目的同级栏目或者父级栏目下的子栏目<!--{if $category.rootid}--> 子栏目的同级栏目 <!--{iCMS:category:list loop="true" row="10" stype="sub" cid="$category.rootid"}--> <!--{/iCMS}--> <!--{else}--> 父级栏目下的子栏目 <!--{iCMS:category:list loop="true" row="10" stype="sub" cid="$category.cid"}--> <!--{/iCMS}--> <!--{/if}-->更简单的写法
<!--{iCMS:category:list loop="true" row="10" stype="sub" cid=$category.rootid|default:$category.cid}--> <!--{/iCMS}--> 
 加载中,请稍侯......
      
评论