Skip to content
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

fix getNext and getPrevious links #3575

Closed
wants to merge 1 commit into from

Conversation

sherifsalah
Copy link

@sherifsalah sherifsalah commented Aug 31, 2020

Description
changed getPrevious to current - 1 to get previous page instead of first -1 that gets first page. same in getNext.

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

changed getPrevious to current - 1 to get previous page instead of first -1 that gets first page. same in getNext.
Copy link
Member

@paulbalandan paulbalandan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried calling first $pager->setSurroundCount() before calling $pager->links()? Current implementation is pretty much desired.

@sherifsalah
Copy link
Author

when i tried to create a custom template already played with $pager->setSurroundCount() and it has no effect, i found out it was not the problem and it was actually always giving my the first or last page anyway .. when i modified the code to the suggested one it works flawlessly (and i guess it should be logically curr+ or curr-. maybe i'm missing something here? can you please elaborate on how current implementation is required?

@paulbalandan
Copy link
Member

@sherifsalah For example, I have the current page set at 5 and I want to have the links before and after (the surroundCount) to be 2 each, that will give me something like this:

3   |  4  |  5  |  6  |  7
  1. If you are looking for going to page 3, use getPrevious
  2. If you are looking for going to page 4, use getPreviousPage
  3. If you are looking for going to page 6, use getNextPage
  4. If you are looking for going to page 7, use getNext

@michalsn
Copy link
Member

@sherifsalah I think you're looking for getPreviousPage() and getNextPage() as mentioned above. I know this might be confusing but we had to do this way because of the compatibility between RC and final release. Please read more about it in the user guide https://codeigniter4.github.io/userguide/libraries/pagination.html (at the bottom of the page).

@paulbalandan
Copy link
Member

@michalsn, I think this can be closed?

@michalsn
Copy link
Member

Yes, I think it's sorted out, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants