Home > php教程 > php手册 > body text

3.1.3多筛选分页路由

WBOY
Release: 2016-06-07 11:37:49
Original
1542 people have browsed it

分享一个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元

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template