🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## sp\_cate (分类列表) >[info] 语法:sp_cate($columnid, $parentid, $number, $options) > 参数:$columnid (必填) > 参数:$parentid (选填 默认:'') > 参数:$number (选填 默认:0) > 参数:options(选填 数组) > 返回值:数组 **调用方法** ``` // 简单用法 方法 1:{assign name="list" value=":sp_cate(100)"} 方法 2:<?php $list= sp_cate(100); ?> // 获取前 5 条 方法 1:{assign name="list" value=":sp_cate(100, '', 5)"} 方法 2:<?php $list= sp_cate(100, '', 5); ?> // 获取 1 级分类 方法 1:{assign name="list" value=":sp_cate(100, 0)"} 方法 2:<?php $list= sp_cate(100, 0); ?> // 获取 1 级分类 前 5 条分类 方法 1:{assign name="list" value=":sp_cate(100, 0, 5)"} 方法 2:<?php $list= sp_cate(100, 0, 5); ?> // 获取 parentid = 5 下面的分类 方法 1:{assign name="list" value=":sp_cate(100, 5)"} 方法 2:<?php $list= sp_cate(100, 5); ?> // 自定义查询语句,自定义排序方式 <?php // wscate_home = 1 首页显示 $options = [ 'where' => 'wscate_columnid = 100 and wscate_home = 1', 'order' => 'wscate_sort asc' ]; // 设置了 where 后,columnid, parentid 将无效。 $list = sp_cate(0, '', 0, $options); ?> ``` **支持字段** >[success] 标题:wscate_title > 名称:wscate_name > 关键词:wscate_keywords > 描述:wscate_description > 内容:wscate_details > 图片:wscate_image 更多字段请查看数据表 site_wscate **调用案例** ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>{$site_home} - {$site_title}</title> <meta name="keywords" content="{$site_keywords}"> <meta name="description" content="{$site_description}"> </head> <body> <h1>分类列表展示</h1> {assign name="list" value=":sp_cate(100)"} {volist name="list" id="vo"} <div><a href="{:url('/news/'.$vo['wscate_page'].'-'.$vo['wscate_id'])}">{$vo['wscate_name']}</a></div> {/volist} </body> </html> ```