简要描述:
- 获取产品分类列表
语法:
{rrz:cats type='top' row='8'}
<!--html内容-->
{/rrz:cats}
属性:
参数名 | 类型 | 默认值 | 必须 | 说明 |
---|---|---|---|---|
id | int | 0 | 是 | 导航id(当type等于top时无效) |
type | string | top | 是 | 数据类型 |
limit | int/string | 0 | 是 | 列表数据量 |
item | string | item | 否 | 循环体变量名 |
key | string | key | 否 | 当前循环是第几个数据(从0开始) |
empty | string/html | 空字符串 | 否 | 无数据时输出的内容 |
- limit=”5” 表示获取前5条数据
- limit=”0,5” 表示从第0个向后获取5条数据
- limit=”1,5” 表示从第1个向后获取5条数据
- 新增 row 属性 row=”5” 等同于 limit=”0,5”
type 的合法值:
值 | 说明 |
---|---|
top | 获取一级数据 |
son | 获取分类id的子集列表 |
self | 获取分类id的数据,此时id可以输入多个用逗号隔开 |
sonself | 获取下级分类或没有下级时获取兄弟列表 |
$item 的常用属性:
值 | 说明 | 代码 |
---|---|---|
url | 链接地址 | {$item.url} |
title | 分类标题 | {$item.title} |
en_title | 英文标题 | {$item.en_title} |
class | 当前样式(等于on时当前页面是该分类页面) | {$item.class?'on':''} |
HTML示例:
获取一级分类
{rrz:cats type='top' row='8'} <div class="pro_box"> <div class="title {if ($key+1)!==1} title1 {/if}"> <a href="{$item.url}">查看更多 +</a> <strong>{$item.title}</strong> </div> </div> {/rrz:cats}
获取子集分类
{rrz:cats id='1' item='cat' type='son' row='3'} <div class="pro_box"> <div class="title {if ($key+1)!==1} title1 {/if}"> <a href="{$cat.url}">查看更多 +</a> <strong>{$cat.title}</strong> </div> </div> {/rrz:cats}
多级嵌套
<!--先获取顶级分类--> {rrz:cats type='top' item='item1' key='key1'} <div class="pro_box"> <div class="title {if ($key1+1)!==1} title1 {/if}"> <a href="{item1.url}">查看更多 +</a> <strong>{item1.title}</strong> </div> <!--使用顶级分类id获取子集 就是二级--> {rrz:cats id='item1.id' item='item2' key='key2' type='son'} <div class="pro_box2"> <div class="title {if ($key2+1)!==1} title1 {/if}"> <a href="{$item2.url}">查看更多 +</a> <strong>{$item2.title}</strong> </div> <!--使用二级分类id获取子集 就是三级--> {rrz:cats id='item2.id' item='item3' key='key3' type='son'} <div class="pro_box3"> <div class="title {if ($key3+1)!==1} title1 {/if}"> <a href="{$item3.url}">查看更多 +</a> <strong>{$item3.title}</strong> </div> </div> {/rrz:cats} </div> {/rrz:cats} </div> {/rrz:cats}
效果展示:
作者:admin 创建时间:2021-04-18 15:46
更新时间:2023-03-09 11:33
更新时间:2023-03-09 11:33