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();

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-26
  • 2021-05-17
  • 2021-11-24
  • 2022-02-26
  • 2021-05-31
猜你喜欢
  • 2021-05-30
  • 2018-12-06
  • 2022-01-20
  • 2022-12-23
  • 2021-06-29
  • 2022-12-23
相关资源
相似解决方案