3.1.3多筛选分页路由
程序员文章站
2022-04-24 12:54:42
...
分享一个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;
设置初始的页码,其他的按照正常的查询写就可以了前台
{$v.region}
然后修改分页类,我是又另外复制了show方法 /**
* 分页显示输出
* @access public
*/
public function routeShow() {
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__';
$parameter=implode('_',$parameter);
$url = U('/list/'.$parameter);
}
//上下翻页字符串
$upRow = $this->nowPage-1;
$downRow = $this->nowPage+1;
if ($upRow>0){
$upPage = "".$this->config['prev']."";
}else{
$upPage = '';
}
if ($downRow totalPages){
$downPage = "".$this->config['next']."";
}else{
$downPage = '';
}
// >>
if($nowCoolPage == 1){
$theFirst = '';
$prePage = '';
}else{
$preRow = $this->nowPage-$this->rollPage;
$prePage = ""; //上5页改成了
$theFirst = "".$this->config['first']."";
}
if($nowCoolPage == $this->coolPages){
$nextPage = '';
$theEnd = '';
}else{
$nextRow = $this->nowPage+$this->rollPage;
$theEndRow = $this->totalPages;
$nextPage = ">>"; // 下5页 改成了 >>
$theEnd = "".$this->config['last']."";
}
// 1 2 3 4 5
$linkPage = "";
for($i=1;$irollPage;$i++){
$page = ($nowCoolPage-1)*$this->rollPage+$i;
if($page!=$this->nowPage){
if($pagetotalPages){
$linkPage .= "".$page.""; //去掉了此处的空格
}else{
break;
}
}else{
if($this->totalPages != 1){
// 当前页
$linkPage .= " ".$page."";
}
}
}
$pageStr = str_replace(
array('%header%','%nowPage%','%totalRow%','%totalPage%','%upPage%','%downPage%','%first%','%prePage%','%linkPage%','%nextPage%','%end%'),
array($this->config['header'],$this->nowPage,$this->totalRows,$this->totalPages,$upPage,$downPage,$theFirst,$prePage,$linkPage,$nextPage,$theEnd),$this->config['theme']);
return $pageStr;
}
对链接重组最后,如果没有筛选的链接路由
'/^list\/(\d+)$/' => 'Index/List/index?p=:1',
有不明白的在评论中留,尽力解答 AD:真正免费,域名+虚机+企业邮箱=0元
推荐阅读