搜尋
首頁php教程php手册thinkphp 分页带有省略号实现方式

thinkphp 分页带有省略号实现方式


public function shows()
{
$adjacents=2;
if(0 == $this->totalRows) return '';
$p = $this->varPage;
$nowCoolPage = ceil($this->nowPage/$this->rollPage);

// 分析分页参数
if($this->url){
$depr = C('URL_PATHINFO_DEPR');
$url = rtrim(U('/'.$this->url,'',false),$depr).$depr.'__PAGE__';
}else{
if($this->parameter && is_string($this->parameter)) {
parse_str($this->parameter,$parameter);
}elseif(is_array($this->parameter)){
$parameter = $this->parameter;
}elseif(empty($this->parameter)){
unset($_GET[C('VAR_URL_PARAMS')]);
$var = !empty($_POST)?$_POST:$_GET;
if(empty($var)) {
$parameter = array();
}else{
$parameter = $var;
}
}
$parameter[$p] = '__PAGE__';
$url = U('',$parameter);
}

//上下翻页字符串
$upRow = $this->nowPage-1;
$downRow = $this->nowPage+1;

// 上一页
if ($upRow>0){
$pages.= "".$this->config['prev']."";
}else{
$pages.= "".$this->config['prev']."";
}

//第一页
if($this->nowPage>($adjacents+1)) {
$pages.= "1";
}

// 添加省略号
if($this->nowPage>($adjacents+2)) {
$pages.= "...";
}

// 12345
$pmin = ($this->nowPage>$adjacents) ? ($this->nowPage-$adjacents) : 1;
$pmax = ($this->nowPagetotalPages-$adjacents)) ? ($this->nowPage+$adjacents) : $this->totalPages;
for($i=$pmin; $i if($i==$this->nowPage) {
$pages.= "".$i."";
}else{
$pages.= "".$i."";
}
}

// 添加省略号
if($this->nowPage totalPages-$adjacents-1)) {
$pages.= "...";
}

// 最后一页
if($this->nowPagetotalPages-$adjacents)) {

$pages.= "totalPages,$url)."'>".$this->totalPages."";
}

// 下一页
if ($downRow totalPages){
$pages.= "".$this->config['next']."";
}else{
$pages.= "".$this->config['next']."";
}
return $pages;
}

添加到分页类中 纯天然绿色无公害。
效果图:
thinkphp 分页带有省略号实现方式

附件下载地址:http://www.esoxue.com/View/view/202.html

AD:真正免费,域名+虚机+企业邮箱=0元

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用