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

Cursor and offset based paginators #30

Open
IonBazan opened this issue Jun 10, 2021 · 1 comment
Open

Cursor and offset based paginators #30

IonBazan opened this issue Jun 10, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@IonBazan
Copy link
Contributor

Just a few things to consider for v4:
Sometimes there is a need to provide an offset-limit pagination instead of human readable "page numbers". This might be useful for API endpoints. Most of the time the offset would match the ($page-1)*$perPage but there might be situations where someone requests offset: 50, limit: 100. A new Adapter (sub)interface could be introduced to address that.
Another idea would be to allow cursor-based navigation, where page ID is a cursor. An example would be Shopify API or AWS Cognito API.

@mbabker mbabker added the enhancement New feature or request label Jun 10, 2021
@stof
Copy link
Contributor

stof commented Dec 13, 2021

The adapter interface actually already implements offset+limit rather than page-based pagination. The handling of pages is handled by the Pagerfanta object. To use a generic offset-based pagination, call $adapter->getSlice() directly.

For cursor-based pagination, I don't think this can be implemented as a generic pagination library, as I don't see how to write a generic logic turning the cursor into a filtering condition on the data source.

@mbabker mbabker added the help wanted Extra attention is needed label Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants