💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# contentpage 内容列表分页 ## 内容列表分页标签 生成页码的分页标签,需要配合内容列表标签使用 > 2.1.220220版本起,新增:可用于内容页,对内容分页 ## 格式示例 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>contentpage item<span class="token">=</span><span class="token4">"home,pre,pageno,next,last,info,jump"</span> <span class="token">/</span><span class="token1">}</span> ``` ``` ## 参数 参数名称可选值默认值是否必填说明itemhome-首页, pre-上一页, pageno-页码, next-下一页, last-尾页, info-数量信息, jump-跳转页码-是分页格式mobile\_item同上--手机端时显示的页码格式,该参数有值时,item则失效。注意:只有在移动端时才有效size-5-显示页码数量。home-首页-首页按钮显示的文字。pre-上一页-上一页按钮显示的文字。next-下一页-下一页按钮显示的文字。last-尾页-尾页按钮显示的文字。info-共 %s 页 / %s 条数据-更改默认数量显示信息,第一个%s是总页数,第二个%s是总条数emptxt-共 %s 页 / %s 条数据-不够分页时显示提示信息hasemptrue/falsetrue-true-显示提示信息,false-不显示## 参数说明 `item` 属性用于控制分页显示项,如下图所示 ![](https://img.kancloud.cn/8a/a4/8aa489f7b2fa63246c14020e8691a39c_831x220.png) 1. 只显示上一页下一页按钮。 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>contentpage item<span class="token">=</span><span class="token4">"pre,next"</span> <span class="token">/</span><span class="token1">}</span> ``` ``` `mobile_item`属性与`item`一致,区别在于仅控制移动端的显示 ``` <pre class="calibre16">``` <span class="token5">// 移动端只显示上一页、页码与下一页</span> <span class="token1">{</span>hkcms<span class="token1">:</span>contentpage item<span class="token">=</span><span class="token4">"pre,next,last,info,jump"</span> mobile_item<span class="token">=</span><span class="token4">"pre,pageno,next"</span> <span class="token">/</span><span class="token1">}</span> ``` ``` `size`控制页码数量,至少五个页码。 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>contentpage item<span class="token">=</span><span class="token4">"pre,next,last,info,jump,pageno"</span> size<span class="token">=</span><span class="token4">"6"</span> <span class="token">/</span><span class="token1">}</span> ``` ``` `home` 控制首页按钮文字,例如首页文字改成字体图标 ``` <pre class="calibre16">``` <span class="token5">// 注意:home="" 里面不能出现双引号、'fa fa-home 是fontawesome图标库</span> <span class="token1">{</span>hkcms<span class="token1">:</span>contentpage item<span class="token">=</span><span class="token4">"home,pre,next,last,pageno"</span> home<span class="token">=</span><span class="token4">"<i class='fa fa-home'></i>"</span> <span class="token">/</span><span class="token1">}</span> ``` ``` ![](https://img.kancloud.cn/b9/a3/b9a35f0824e2d619563fadbc00e3cfd0_437x102.png) `pre`控制上一页按钮文字、`next`控制下一页按钮文字、`last`控制尾页按钮文字、设置方法同上一致 `info` 属性是控制分页信息。默认格式为:**共 %s 页 / %s 条数据**,第一个%s是总页数,第二个%s是总条数,例如上面图片中的**共 2 页 11 条数据** 例如:分页信息改为:共 2 页,总共 11 个产品 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>contentpage item<span class="token">=</span><span class="token4">"pre,next,pageno,info"</span> info<span class="token">=</span><span class="token4">"共 %s 页,总共 %s 个产品"</span> <span class="token">/</span><span class="token1">}</span> ``` ``` `emptxt`属性是对不够分页显示的提示信息,如下 ![](https://img.kancloud.cn/9f/d3/9fd3de9083e954d0a86393a200675142_184x73.png) 修改方式同上 `hasemp`属性是对不够分页的提示信息控制显示隐藏,true-显示提示信息,false-不显示 ``` <pre class="calibre16">``` <span class="token5">// 默认显示,hasemp="false" 为隐藏</span> <span class="token1">{</span>hkcms<span class="token1">:</span>contentpage item<span class="token">=</span><span class="token4">"pre,next,pageno,info"</span> hasemp<span class="token">=</span><span class="token4">"false"</span> <span class="token">/</span><span class="token1">}</span> ``` ``` ## 示例 - 完整示例 每页显示10条记录 ``` <pre class="calibre16">``` <span class="token5">// 结合内容列表标签</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"1"</span> page<span class="token">=</span><span class="token4">"1"</span> num<span class="token">=</span><span class="token4">"10"</span><span class="token1">}</span> <span class="token"><</span>p<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>p<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> <span class="token"><</span>div<span class="token">></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,jump"</span> <span class="token">/</span><span class="token1">}</span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> ``` ``` 结果图,生成的html有带class,可自行写class样式定义分页风格。根据自己的需要,可自定义分页显示的项。 ![](https://img.kancloud.cn/94/55/94555c4bbbb463ca1990b8999cdc758e_686x171.png) - 移动端覆盖默认的格式 如下代码所示,在移动端是,mobile\_item覆盖item格式。移动端只显示上一页,页码,下一页。 ``` <pre class="calibre16">``` <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> ``` ``` - 修改不够分页提示信息 默认显示共1页,1条数据,使用emptxt属性,可修改 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>contentpage item<span class="token">=</span><span class="token4">"pre,pageno,next"</span> mobile_item<span class="token">=</span><span class="token4">"pre,pageno,next"</span> emptxt<span class="token">=</span><span class="token4">"共%s页"</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> ``` ``` - 隐藏不够分页的提示信息。 使用hasemp参数 ``` <pre class="calibre20">``` <span class="token1">{</span>hkcms<span class="token1">:</span>contentpage item<span class="token">=</span><span class="token4">"pre,pageno,next"</span> mobile_item<span class="token">=</span><span class="token4">"pre,pageno,next"</span> hasemp<span class="token">=</span><span class="token4">"true"</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> ``` ```