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

Where does $uri->currentPage() come from? #47

Open
NicoHood opened this issue Sep 5, 2020 · 2 comments
Open

Where does $uri->currentPage() come from? #47

NicoHood opened this issue Sep 5, 2020 · 2 comments

Comments

@NicoHood
Copy link

NicoHood commented Sep 5, 2020

The plugin uses $uri->currentPage() in multiple lines. For example:

$start = ($uri->currentPage() - 1) * $limit;

It uses a grav API:
https://learn.getgrav.org/16/api#class-grav-common-uri

I am wondering: How does it work? Does the Grav API read the URI and searches for page:<number>? To me this sounds strange, as the pagination should only be provided by the plugin, not by grav itself. I would have expected, that this is a plugin function, not a common API function.

Could you please clarify?

@mahagr
Copy link
Member

mahagr commented Sep 14, 2020

https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Uri.php#L542-L547

So yes, it looks into the current URL and returns the value of /page:1 parameter.

To be honest, I don't think that we should have a pagination plugin at all. My reasoning is that pagination should be in Grav core and then used by whatever data type you happen to have. Also you may have pagination inside some sidebar content which is using AJAX to load extra information. In this case, the logic in the plugin is too limited. There are already pagination classes added to Grav itself:
https://github.com/getgrav/grav/tree/develop/system/src/Grav/Framework/Pagination

@NicoHood
Copy link
Author

NicoHood commented Sep 14, 2020

I agree. There should be either an independent plugin or a full working builtin solution. I guess you have that on the roadmap or somewhere? Should we keep this open?

Edit: I want to add, that having a plugin is nice in the way to easily copy and modify the plugin. For example I find it confusing using extra urls for pagination instead of query parameters. Is there a special reason for that design decision? At least with a plugin you could overcome this issue (and thatswhy I stumbled across this function).

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

No branches or pull requests

2 participants