分页后缀在以前的链接上不工作 [英] pagination suffix doesn't work on previous links

查看:82
本文介绍了分页后缀在以前的链接上不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的分页代码中

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

所以在第一页它工作正常,当我点击page2它去

so in the first page it works fine when i click on page2 it goes to

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

但在第二页中,如果我点击第一页或上一页(<),它会转到

but in the second page if i click on page one or previous page ( < ) it goes to

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

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

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

doesn't work in the previous links!

推荐答案

我发现并修复了与第一页链接与其他网页链接不一致的错误。我建议在Github repo中使用当前版本扩展Pagination库,直到CodeIgniter 3.0发布,这时它将是内置的,你可以删除你的扩展库。

I found and fixed a bug that was related to the first page links being inconsistent with the rest of the page links. I'd suggest extending the Pagination library with the current version in the Github repo until CodeIgniter 3.0 is released, at which point it will be built-in and you can remove your extended lib.

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

The new version also has a config option called reuse_query_string, which when set to TRUE will keep any existing query strings. So if they are already present when you reach the page, you do not need to worry about specifying them as a suffix.

$config['reuse_query_string'] = TRUE;

当前库文件: https://github.com/EllisLab/CodeIgniter/blob/develop/system/libraries/Pagination.php
相关拉取请求并提供信息: https://github.com/EllisLab/CodeIgniter/pull/2199

这篇关于分页后缀在以前的链接上不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆