
pagelist列表分页标签实现数字分页前后的省略号
更新日期:2024-06-15 23:27:08 来源:网络


实现教程如下:
1、编辑列表模板,把分页标签pagelist加上一个标识pageno,dots,参考代码
{eyou:pagelist listitem='pre,next,info,index,end,pageno,dots' listsize='1' /}
2、由于每个模板分页样式不同,涉及的分页php文件官方不会在线更新覆盖,请根据步骤找到分页php文件补充相关代码。
2.1、用编辑器(非记事本工具)打开文件 core/library/paginator/driver/Eyou.php (注:Eyou.php为pc分页文件,手机端的为:Mobile.php)
2.2、在108行左右找到代码 protected function getLinks($listsize = 3) 替换成 protected function getLinks($listsize = 3, $listitemArr = [])

2.3、把109行大括号 { 开始,到对应大括号 } 结束的代码进行替换
/**
* 页码按钮
* @param string $listsize 当前页对称两边的条数
* @return string
*/
protected function getLinks($listsize = 3, $listitemArr = [])
{
这里全部代码都要被替换为2.4步骤的代码
}
替换成以下代码:
/**
* 页码按钮
* @param string $listsize 当前页对称两边的条数
* @return string
*/
protected function getLinks($listsize = 3, $listitemArr = [])
{
if ($this->simple)
return '';
$block = [
'first' => null,
'slider' => null,
'last' => null
];
$side = $listsize;
$window = $side * 2;
if ($this->lastPage < $window + 2) {
$block['first'] = $this->getUrlRange(1, $this->lastPage);
} elseif ($this->currentPage < ($side + 1)) {
$block['first'] = $this->getUrlRange(1, $window + 1);
} elseif ($this->currentPage > ($this->lastPage - $side)) {
$block['last'] = $this->getUrlRange($this->lastPage - $window, $this->lastPage);
} else {
$block['slider'] = $this->getUrlRange($this->currentPage - $side, $this->currentPage + $side);
}
$html = '';
if (is_array($block['first'])) {
$html .= $this->getUrlLinks($block['first']);
if (in_array('dots', $listitemArr)) {
if ($window + 1 < $this->lastPage) {
if ($window + 1 < $this->lastPage - 1) {
$html .= $this->getDots();
}
$html .= $this->getPageLinkWrapper2($this->url($this->lastPage), $this->lastPage);
}
}
}
if (is_array($block['slider'])) {
if (in_array('dots', $listitemArr)) {
if ($this->currentPage - $side > 1) {
$html .= $this->getPageLinkWrapper2($this->url(1), 1);
if ($this->currentPage - $side > 2) {
$html .= $this->getDots();
}
}
}
$html .= $this->getUrlLinks($block['slider']);
if (in_array('dots', $listitemArr)) {
if ($this->currentPage + $side < $this->lastPage) {
if ($this->currentPage + $side < $this->lastPage - 1) {
$html .= $this->getDots();
}
$html .= $this->getPageLinkWrapper2($this->url($this->lastPage), $this->lastPage);
}
}
}
if (is_array($block['last'])) {
if (in_array('dots', $listitemArr)) {
if ($this->lastPage - $window < $this->lastPage) {
$html .= $this->getPageLinkWrapper2($this->url(1), 1);
if ($this->lastPage - $window > 2) {
$html .= $this->getDots();
}
}
}
$html .= $this->getUrlLinks($block['last']);
}
return $html;
}
2.4、看下图找到这个代码 array_push($pageArr, $this->getLinks($listsize)); 替换成 array_push($pageArr, $this->getLinks($listsize, $listitemArr));

完结。

- 请问如何处理升级为香港主机后网站无法访问的问题
- 防火墙设置与云服务器80端口访问限制
- 解决远程登录服务器失败及重启后仍无法连接的问题
- 远程访问故障排除 - 解决无法登录虚拟主机和数据库的问题
- 解析与绑定完成后网站仍无法正常访问的排查步骤及解决方案
- 请问如何在ASP页面中判断客户端浏览器是否为移动设备,并进行相应的跳转?
- 输入网站后台密码时显示不对,如何解决?
- 选择合适工具,掌握静态网站模板修改方法
- 静态网站上传后如何安全有效地进行修改,确保不影响网站的正常运行?
- 请问如何修改网站图片源代码
- 网站admin密码忘记了怎么办
- 如何解决PbootCMS网站后台推送文章到百度时的“site error”错误?
- 迅睿CMS网站用户投稿如何取消验证码
- 宝塔面板提示不是安全连接或私密连接,如何解决?
- 网站提示429 Too Many Requests:用户发送了太多请求怎么办
- 易优cms搜索结果页如何统计关键词文章数量
- 网站源码安装后访问首页,页面错乱的处理方法
- pbootcms模板如何做好防护
- 重置网站后台管理员账号密码
- 升级完后网站提示500错误怎么办
- pbootcms如何设置发布内容不自动提取缩略图(1)
- 百度网址安全中心提醒您:该页面可能存在违法信息!如何处理?
- 易优cms数据表或视图不存在,请联系技术处理。
- Pbootcms留言“提交成功”的提示语修改(1)
- PBOOTCMS中新增并开启手机端模板,以便为用户提供更好的移动设备浏览体验
- imagecreatefrompng(): gd-png: libpng warning: iCCP: known incorrect sRGB profile
- 易优CMS文章内容页如何获取上一篇下一篇
- PbootCMS全站模板date时间标签/时间格式常见的8种调用方式
- pbootcms网站后台登录提示:”登录失败:数据库目录写入权限不足!“
- Nginx 启动/停止 / 首页显示 / 安装 / 卸载