http://www.thinkphp.cn/topic/22114.html
最终目的实现以http://www.fl900.com/product/lists/1-0-0-1.html这样的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();
评论(0)