hi this in my pagination code
$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();
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
this
$config['suffix'] = '?'.http_build_query($_GET, '', "&");
doesn't work in the previous links!
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.
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;
Current library file: https://github.com/EllisLab/CodeIgniter/blob/develop/system/libraries/Pagination.php Related pull request with info: https://github.com/EllisLab/CodeIgniter/pull/2199
You can set the first_url
as following if you don't want to change the library:
$config['first_url'] = $config['base_url'] . $config['suffix'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With