thinkphp5 怎么修改分页的url地址
展开全部
路由配置:
'/^product\/lists\/(\d+)-(\d+)-(\d+)-(\d+)$/' => 'Product/lists?id=:1&aid=:2&sid=:3&p=:4',
复制代码
修正Library\Think\Page.class.php分类以支持路由
//在23行,修改访问修饰符private为public
public $url='';
//在70行,防止经过传参后会出现问题urlencode('[PAGE]')转为小写,修改为
$this->url = str_replace(strtolower(urlencode('[PAGE]')), $page, $this->url);//开启URL不区分大小写时处理
return str_replace(urlencode('[PAGE]'), $page, $this->url);
//在80行,修正为以下实现自定义URL
/* 生成URL */
if(empty($this->url)){
$this->parameter[$this->p] = '[PAGE]';
$this->url = U(ACTION_NAME, $this->parameter);
}
//使用示例
$Page = new \Think\Page($count,15);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$page_tpl = urlencode('[PAGE]');
$Page->url = U("Product/list/{$this->id}-{$this->aid}-{$this->sid}-{$page_tpl}");
$show = $Page->show();
'/^product\/lists\/(\d+)-(\d+)-(\d+)-(\d+)$/' => 'Product/lists?id=:1&aid=:2&sid=:3&p=:4',
复制代码
修正Library\Think\Page.class.php分类以支持路由
//在23行,修改访问修饰符private为public
public $url='';
//在70行,防止经过传参后会出现问题urlencode('[PAGE]')转为小写,修改为
$this->url = str_replace(strtolower(urlencode('[PAGE]')), $page, $this->url);//开启URL不区分大小写时处理
return str_replace(urlencode('[PAGE]'), $page, $this->url);
//在80行,修正为以下实现自定义URL
/* 生成URL */
if(empty($this->url)){
$this->parameter[$this->p] = '[PAGE]';
$this->url = U(ACTION_NAME, $this->parameter);
}
//使用示例
$Page = new \Think\Page($count,15);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$page_tpl = urlencode('[PAGE]');
$Page->url = U("Product/list/{$this->id}-{$this->aid}-{$this->sid}-{$page_tpl}");
$show = $Page->show();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询