New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pagination uri_segment hard coded to 3? #1476
Comments
I've encountered this too. I'll work on a fix later today. |
The default is set to 3, but I don't see what is the problem, as you can change it... Please, read the user guide (quote): The following is a list of all the preferences you can pass to the initialization function to tailor the display. The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it. |
See the above commit. |
In the built-in pagination class (libraries/Pagination.php) the variable $uri_segment is hard coded to a value of 3. This is normally the segment of the uri that contains the current page (so the links can format properly), but if you set a base_url with more than 2 segments the links created no longer function correctly.
Example (works as expected):
This produces the links which correctly highlight the current page, move correctly from previous to next, etc, since the uri_segment for 3 would be the generated page number. (controller/function/[page inserted by pagination]). If you add on another segment to the base_url, however, the uri_segment is no longer 3, but some larger value.
Example (broken):
The current page is at a uri_segment of 4 now, not 3. So if you click on page 2, for example, it correctly generates the link (controller/function/param1/[page inserted by pagination], but the current page is no longer displayed correctly. This limitation forces any function using pagination to not have any parameters when enable_query_strings is not set, which is annoying.
Simple fix which worked for me, but probably would not for all cases:
After adding this line the links correctly pulled the current page.
The text was updated successfully, but these errors were encountered: