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

Ability to paginate with feeds that provide a page number instead of the next page URL. #821

Open
wants to merge 2 commits into
base: 5.x
Choose a base branch
from

Conversation

chriscborg
Copy link

Description

This PR adds the ability to check the next page URL for the case where a page number is provided instead of the next page's URL. Some feeds only provide the current page information instead of the URL to the next page. Example of such feed below:

{
    "data":[
      ...
    ],
    "paging": {
        "page": 1,
        "perPage": 200,
        "pageCount": 13
    }
}

In this case, we are checking if the data provided as the next page is numeric, and a total page number is provided as well. In this case, we generate a URL using the feedUrl and appending the query string ?page={number} by incrementing the current page number. This is then repeated until the total page count provided is reached.

What is included:

  • The addition of the new field to provide the total pages
  • Edited the description in the settings form to explain that a page number can be provided instead of a URL
  • Added a database migration file to add the total page number
  • Incremented the plugin version number for migration (not sure if this is allowed)
  • Added the functionality mentioned above the to the setupPaginationUrl($array, $feed) function in the DataType class, making use of the UrlHelper function to add the query string

What is not included

  • I was not able to run the unit tests as I was getting errors while running, therefore I was not able to confirm if tests are ok, or even add any if needed. Help on this would be appreciated
  • I also was not able to test on feeds that provide a normal next page URL.

In general, help in testing would be appreciated.

Related Issues

I apologise for not creating an issue before, but I needed this feature anyway for a project I'm working on.

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.

None yet

1 participant