💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# tagarclist根据标签获取文章内容列表 ## tagarclist根据标签获取文章内容列表 用于**根据标签获取文章列表** > 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 类名,用于定义当前选择状态样式## 简单示例. 在标签页`tags_list`页面,获取文章列表 ``` <pre class="calibre16">``` <span class="token5">// 在标签列表页有$Tags变量,即当前标签,这里代码意思是:获取当前标签下的文章。里面的字段是文章的字段</span> <span class="token1">{</span>hkcms<span class="token1">:</span>tagarclist tid<span class="token">=</span><span class="token4">"$Tags['id']"</span> num<span class="token">=</span><span class="token4">"6"</span> page<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> title<span class="token">=</span><span class="token4">"{$item.title}"</span><span class="token">></span><span class="token"><</span>img src<span class="token">=</span><span class="token4">"{:cdn_url($item.thumb)}"</span> style<span class="token">=</span><span class="token4">"object-fit: cover;"</span> alt<span class="token">=</span><span class="token4">"{$item.title}"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token"><</span>h5<span class="token">></span><span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> title<span class="token">=</span><span class="token4">"{$item.title}"</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>h5<span class="token">></span> <span class="token"><</span>h6<span class="token">></span><span class="token1">{</span>hkcms<span class="token1">:</span>date name<span class="token">=</span><span class="token4">"$item['publish_time']"</span> <span class="token">/</span><span class="token1">}</span><span class="token"><</span><span class="token">/</span>h6<span class="token">></span> <span class="token"><</span>p class<span class="token">=</span><span class="token4">"card-text"</span><span class="token">></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>description<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>p<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>tagarclist<span class="token1">}</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> ``` ``` 在其他位置获取,例如你的标签ID是10,那么获取文章里面有10的标签列表 ``` <pre class="calibre20">``` <span class="token5">// 在标签列表页有$Tags变量,即当前标签,这里代码意思是:获取当前标签下的文章。里面的字段是文章的字段</span> <span class="token1">{</span>hkcms<span class="token1">:</span>tagarclist tid<span class="token">=</span><span class="token4">"10"</span> num<span class="token">=</span><span class="token4">"6"</span> <span class="token1">}</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> title<span class="token">=</span><span class="token4">"{$item.title}"</span><span class="token">></span><span class="token"><</span>img src<span class="token">=</span><span class="token4">"{:cdn_url($item.thumb)}"</span> style<span class="token">=</span><span class="token4">"object-fit: cover;"</span> alt<span class="token">=</span><span class="token4">"{$item.title}"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token"><</span>h5<span class="token">></span><span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> title<span class="token">=</span><span class="token4">"{$item.title}"</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>h5<span class="token">></span> <span class="token"><</span>h6<span class="token">></span><span class="token1">{</span>hkcms<span class="token1">:</span>date name<span class="token">=</span><span class="token4">"$item['publish_time']"</span> <span class="token">/</span><span class="token1">}</span><span class="token"><</span><span class="token">/</span>h6<span class="token">></span> <span class="token"><</span>p class<span class="token">=</span><span class="token4">"card-text"</span><span class="token">></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>description<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>p<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>tagarclist<span class="token1">}</span> ``` ```