🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# taglist标签(获取标签列表) ## taglist标签 用于**获取标签列表** > HkCms\_2.2.4.230206版本起 ## 参数 参数名称可选值默认值是否必填说明tid标签ID或0--0-表示获取所有arcid文章ID-tid与arcid选一个获取指定文章包含的标签model模型ID-acrid填写时,该值不能为空指定标签属于的模型catid栏目ID--指定标签属于的栏目order-views desc(点击量降序)-排序num---限制结果数量where---sql筛选条件page1--开启分页,配合 {hkcms:contentpage /} 分页标签id-$item-指定循环里的变量名,例如id='obj',模板调用如:{$item.title} 变成 {$obj.title}empty--否为空的时候输出提示,支持传入htmlcache-3600秒-缓存时间,默认3600秒currentstyle-active-css class 类名,用于定义当前选择状态样式## 简单示例 1\. 获取所有标签 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>taglist tid<span class="token">=</span><span class="token4">"0"</span><span class="token1">}</span> <span class="token1">{</span>php<span class="token1">}</span><span class="token6">dump</span><span class="token1">(</span>$item<span class="token1">)</span><span class="token1">;</span><span class="token1">{</span><span class="token">/</span>php<span class="token1">}</span> <span class="token5">// 输出所有字段</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>taglist<span class="token1">}</span> ``` ``` 2\. 获取指定标签 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>taglist tid<span class="token">=</span><span class="token4">"3"</span><span class="token1">}</span> <span class="token1">{</span>php<span class="token1">}</span><span class="token6">dump</span><span class="token1">(</span>$item<span class="token1">)</span><span class="token1">;</span><span class="token1">{</span><span class="token">/</span>php<span class="token1">}</span> <span class="token5">// 输出所有字段</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>taglist<span class="token1">}</span> ``` ``` 3\. 文章详情页,获取当前文章所有标签,也可用于列表页 详情页: ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>taglist arcid<span class="token">=</span><span class="token4">"$Info.id"</span> model<span class="token">=</span><span class="token4">"$Info.model_id"</span><span class="token1">}</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span><span class="token">></span><span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>taglist<span class="token1">}</span> ``` ``` 4\. 只获取特定模型的标签 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>taglist model<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span> <span class="token1">{</span>php<span class="token1">}</span><span class="token6">dump</span><span class="token1">(</span>$item<span class="token1">)</span><span class="token1">;</span><span class="token1">{</span><span class="token">/</span>php<span class="token1">}</span> <span class="token5">// 输出所有字段</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>taglist<span class="token1">}</span> ``` ``` 5\. 只获取特定栏目的标签(1.0.3版本) ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>taglist catid<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span> <span class="token1">{</span>php<span class="token1">}</span><span class="token6">dump</span><span class="token1">(</span>$item<span class="token1">)</span><span class="token1">;</span><span class="token1">{</span><span class="token">/</span>php<span class="token1">}</span> <span class="token5">// 输出所有字段</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>taglist<span class="token1">}</span> ``` ``` 5\. 分页,page=1:开启分页,num=10,每页显示10条记录 ``` <pre class="calibre20">``` <span class="token1">{</span>hkcms<span class="token1">:</span>taglist tid<span class="token">=</span><span class="token4">"0"</span> page<span class="token">=</span><span class="token4">"1"</span> num<span class="token">=</span><span class="token4">"10"</span> order<span class="token">=</span><span class="token4">"views desc"</span><span class="token1">}</span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"col-xs-3"</span><span class="token">></span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> target<span class="token">=</span><span class="token4">"_blank"</span><span class="token">></span><span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>taglist<span class="token1">}</span> <span class="token5">// 显示页码</span> <span class="token1">{</span>hkcms<span class="token1">:</span>contentpage item<span class="token">=</span><span class="token4">"home,pre,pageno,next,last,info"</span> mobile_item<span class="token">=</span><span class="token4">"pre,pageno,next"</span> pre<span class="token">=</span><span class="token4">"&laquo;"</span> next<span class="token">=</span><span class="token4">"&raquo;"</span> <span class="token">/</span><span class="token1">}</span> ``` ```