2013-03-05 24 views
4

喜当我在第2页点击进入分页后缀不上以前的链接工作

http://mysite.com/cp/orders/20?sort=id&adc=desc 

但是这在我分页代码

$config['base_url'] = base_url().'cp/orders/'; 
$config['suffix'] = '?'.http_build_query($_GET, '', "&"); 
$config['uri_segment'] = 3; 
$config['total_rows'] = $count_all; 
$config['per_page'] = 20 ; 
$this->pagination->initialize($config); 
echo $this->pagination->create_links(); 

所以在第一页,它工作正常如果我点击一个页面或前一页(<)在第二页它去

http://mysite.com/cp/orders/20 

$config['suffix'] = '?'.http_build_query($_GET, '', "&"); 

在以前的链接中不起作用!

+0

它去https://github.com/EllisLab/CodeIgniter/blob/develop/system/libraries/Pagination.php 与信息相关的拉动请求回到'per_page'上的主配置,你是否尝试在'per_page'上添加相同的后缀? – tomexsans 2013-03-06 00:13:27

+0

@tomexsans我不确定你在'per_page'里加了后缀是什么意思,但是我已经在'$ config ['per_page'] = 20后面加后缀了',但是它不会改变 – max 2013-03-07 16:25:17

回答

3

我发现并修正了与第一页的链接是与页面链接的其余部分不一致的错误。我建议使用Github repo中的当前版本扩展分页库,直到CodeIgniter 3.0发布,此时它将是内置的,并且您可以删除扩展的库。

新版本还有一个名为reuse_query_string的配置选项,当设置为TRUE时,它将保留任何现有的查询字符串。因此,如果它们在到达页面时已经存在,则不必担心将它们指定为后缀。

$config['reuse_query_string'] = TRUE; 

当前库文件:https://github.com/EllisLab/CodeIgniter/pull/2199

3

您可以设置first_url如下,如果你不希望改变库:

$config['first_url'] = $config['base_url'] . $config['suffix'];