search
Homephp教程php手册3.1.3多筛选分页路由

分享一个3.1.3多筛选分页路由,我是新手,如果不正确的地方望大家使劲喷
分享一个3.1.3多筛选分页路由,我是新手,如果不正确的地方望大家使劲喷
首先设置路由规则,因为我的是筛选是类所以路由设置为 '/^list\/(\d+)_(\d+)_(\d+)_(\d+)_(\d+)$/' => 'Index/List/index?r=:1&t=:2&n=:3&y=:4&p=:5',然后方法中写  $this->p = isset($_GET['p'])?(int)$_GET['p'] : 1; 设置初始的页码,其他的按照正常的查询写就可以了
前台<a>{$v.region}</a>然后修改分页类,我是又另外复制了show方法    /**<br>      * 分页显示输出<br>      * @access public<br>      */<br>     public function routeShow() {<br>         if(0 == $this->totalRows) return '';<br>         $p              =   $this->varPage;<br>         $nowCoolPage    =   ceil($this->nowPage/$this->rollPage);<br> <br>         // 分析分页参数<br>         if($this->url){<br>             $depr       =   C('URL_PATHINFO_DEPR');<br>             $url        =   rtrim(U('/'.$this->url,'',false),$depr).$depr.'__PAGE__';<br>         }else{<br>             if($this->parameter && is_string($this->parameter)) {<br>                 parse_str($this->parameter,$parameter);<br>             }elseif(is_array($this->parameter)){<br>                 $parameter      =   $this->parameter;<br>             }elseif(empty($this->parameter)){<br>                 unset($_GET[C('VAR_URL_PARAMS')]);<br>                 $var =  !empty($_POST)?$_POST:$_GET;<br>                 if(empty($var)) {<br>                     $parameter  =   array();<br>                 }else{<br>                     $parameter  =   $var;<br>                 }<br>             }<br>               $parameter[$p]  =   '__PAGE__';<br>             $parameter=implode('_',$parameter);<br>             $url      =   U('/list/'.$parameter);<br>         }<br>         //上下翻页字符串<br>         $upRow          =   $this->nowPage-1;<br>         $downRow        =   $this->nowPage+1;<br>         if ($upRow>0){<br>             $upPage     =   "<a>".$this->config['prev']."</a>";<br>         }else{<br>             $upPage     =   '';<br>         }<br> <br>         if ($downRow totalPages){<br>             $downPage   =   "<a>".$this->config['next']."</a>";<br>         }else{<br>             $downPage   =   '';<br>         }<br>         //  >><br>         if($nowCoolPage == 1){<br>             $theFirst   =   '';<br>             $prePage    =   '';<br>         }else{<br>             $preRow     =   $this->nowPage-$this->rollPage;<br>             $prePage    =   "<a>"; //上5页改成了              $theFirst   =   "</a><a>".$this->config['first']."</a>";<br>         }<br>         if($nowCoolPage == $this->coolPages){<br>             $nextPage   =   '';<br>             $theEnd     =   '';<br>         }else{<br>             $nextRow    =   $this->nowPage+$this->rollPage;<br>             $theEndRow  =   $this->totalPages;<br>             $nextPage   =   "<a>>></a>";    // 下5页 改成了 >><br>             $theEnd     =   "<a>".$this->config['last']."</a>";<br>         }<br>         // 1 2 3 4 5<br>         $linkPage = "";<br>         for($i=1;$irollPage;$i++){<br>             $page       =   ($nowCoolPage-1)*$this->rollPage+$i;<br>             if($page!=$this->nowPage){<br>                 if($pagetotalPages){<br>                     $linkPage .= "<a>".$page."</a>"; //去掉了此处的空格<br>                 }else{<br>                     break;<br>                 }<br>             }else{<br>                 if($this->totalPages != 1){<br>                     // 当前页<br>                     $linkPage .= " <span>".$page."</span>";<br>                 }<br>             }<br>         }<br>         $pageStr     =   str_replace(<br>             array('%header%','%nowPage%','%totalRow%','%totalPage%','%upPage%','%downPage%','%first%','%prePage%','%linkPage%','%nextPage%','%end%'),<br>             array($this->config['header'],$this->nowPage,$this->totalRows,$this->totalPages,$upPage,$downPage,$theFirst,$prePage,$linkPage,$nextPage,$theEnd),$this->config['theme']);<br>         return $pageStr;<br>     }对链接重组
最后,如果没有筛选的链接路由    '/^list\/(\d+)$/' => 'Index/List/index?p=:1',有不明白的在评论中留,尽力解答

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment