CodeIgniter Forums
Pagination library, first_url bug in previous link - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Pagination library, first_url bug in previous link (/showthread.php?tid=60021)



Pagination library, first_url bug in previous link - El Forum - 12-29-2013

[eluser]Unknown[/eluser]
Hi,

I think something is missing in the Pagination library.

Suppose I want to do the following:

http://www.mydomain.com/category/name contains first 30 entries of a certain category
http://www.mydomain.com/category/name/2 contains the next 30 entries of a certain category

I set the $config['first_url'] to http://www.mydomain.com/category/name
this will make the url for "First" and "1" point to the correct http://www.mydomain.com/category/name
but the url for "Previous" points to http://www.mydomain.com/category/name/1

in the Pagination library code there is the following:

Code:
if ($this->use_page_numbers)
{
$i = $uri_page_number - 1;
}
...
if ($i == 0 && $this->first_url != '')
{
... //custom first url
}
else{
... //url with page number
}

but if you're at page 2, $uri_page_number will be 2, $i will be 1 so the case for the custom first url doesn't get executed because the check is for $i == 0 instead of $i == 1

What do you guys think?