search
Homephp教程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元

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools