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
[RFC] Added data-pagination to view output. #92
[RFC] Added data-pagination to view output. #92
Conversation
The data attribute is a json_encoded array of the following: * url * totalResults * totalPages * currentPage * currentPageOffsetStart * currentPageOffsetEnd This update makes it easier to add other JS hooks / events.
This should be optional, thus the views work the same as before by default. Also tests should be passing (some of the views are not passing now), and you should add tests for this as well. |
|
||
private function getPaginationData(){ | ||
return array( | ||
"url" => $this->template->generateRoute(null), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can access to the route generator in the view directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. How? I can see it anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/whiteoctober/Pagerfanta/blob/master/src/Pagerfanta/View/DefaultView.php#L47
The route generator is injected from the view the the template:
https://github.com/whiteoctober/Pagerfanta/blob/master/src/Pagerfanta/View/DefaultView.php#L79
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm probably daft but I don't understand. Are you suggesting that the router should be saved as a class variable in the DefaultView
class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, using somehow the routegenerator that is already in the view.
Do you plan to finish this? |
I do. I was justa bit confused. To clarify you're suggesting: When the RouteGenerator is passed into configureTemplate() set a class variable on DefaultView? |
Or just in the |
@@ -23,14 +23,15 @@ class DefaultTemplate extends Template | |||
'css_dots_class' => 'dots', | |||
'css_current_class' => 'current', | |||
'dots_text' => '...', | |||
'container_template' => '<nav>%pages%</nav>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why removing the option?
Could you rebase and add documentation for this please? |
Do you plan to do this? |
Are you alive? :) |
The data attribute is a json_encoded array of the following:
Builds on top off PR #91
Is this something that interests anyone?
This update makes it easier to add other JS hooks / events. I'm currently using it to build a perPage select box:
The method in my widget looks like: