-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Bug: pager "prev" and "next" links pointing to wrong URIs #2881
Comments
You seem to have found a solution, Can you try to fix ? |
I would love to, but i first want to confirm that this is an expected behavior since the comments on those functions state something else. Both functions say:
I dont know why this is the expected behavior and whether or not i should change it? |
This is expected behavior. “Previous” and “Next” do not refer to the pages but to the row of links. The documentation isn’t super clear but read up on the pagination methods: https://codeigniter4.github.io/userguide/libraries/pagination.html#creating-the-view |
Ok, but how is it rational to not have a "next page" and "previous page" buttons in a pagination? I see there are methods about that - maybe i should just write my own view, to get rid of this. |
I applied a PR that fits this, since it doesn't make much sense for "next" and "prev" to be for a paging group when in fact the global understanding of pagination means that "next" and "prev" are linked directly to pages . |
I think this feature or bug could be useful when jumping through huge data sets, so I don't think this should be removed. It definitely needs to be renamed though. From a front end user stand point there needs to be a way to just increment/decrement the page without setting setSurroundCount(0) eliminating most of the point of pagination. Even W3C states this basic functionality, although quite ambiguously, at https://www.w3.org/dpub/IG/wiki/Pagination_Requirements#Ability_to_select_page.28s.29_for_display Currently I'm using what @korgoth suggested and have been doing so since release. |
@lonnieezell I noticed that in the v4.0.3 release that you stated that this issue has been fixed, however when I download a copy of the ZIP or Tar file the code doesn't reflect this. When compared with the commit for that release the code does reflect the changes in the commit, but not the download. Also the develop branch does not reflect the change to pagination either. I haven't compared all the fixes in the release, so there may be other changes that didn't make it to the release. Am I missing something or does it appear to anyone else that the code in the download mostly reflects the current develop branch. |
@durbintl I see the updated code in the release commit to When I download it I have the same code. Can you specify where you are going to download? |
@MGatner I'm pulling from multiple sources with the same results as noted below.
To ensure I don't have any heavy caching going on for some reason I spun up a VM and double checked. All yield the same results, which do not seem to be the same as the commit you provided. The file I am specifically looking at as comparison is at system/Pager/PagerRenderer.php codeigniter4/framework@edd88b1#diff-a49d9d6f18fe7684d344c5f7ecf34e1b |
I checked again and everything seems fine. |
While paginating a model i noticed that when rendered my "prev" and "next" links point to the wrong URIs.
The result has 116 entries and they are limited to 20 per page using:
And then simply displaying it using:
This results in the following HTML being rendered when i am on Page 1:
Now i noticed that while on page number 1, the "next" link pointed to page number 4. Similarly on page 2 - next pointed to page 5, on page 3 next pointed to 6.
The "prev" button does exactly the same - with the same offset of 3 pages.
I tried digging up the CI code and noticed that the problem seems to be in the PageRenderer class. In that class the functions getPrevious() and getNext() seem to be referring and modifying the $this->first and $this->last property, as i think they should be modifying the $this->current
Current code in system/Pager/PagerRenderer.php starting from line 36 is:
I think it should be:
CI Version: 4.0.2
Affected modules: Pager
Expected behavior: Pager "next" link to lead to the next page, and not to the next "set of non-displayed page links (due to surround links limit) "
The text was updated successfully, but these errors were encountered: