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

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 Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

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

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),