h4r4ld Posted December 8, 2015 Share Posted December 8, 2015 HI hi I'm currently working on pageination my documentlisting. I Have enabled the MarkupPagerNav module and activated allow page numbers on the documentholder template. I'm using some different selectors, but as for the tests I would go with this one : $documentHolder = $pages->find("template=documentHolder, status=hidden, limit=2, sort=created, docownerid={$user->id}"); the documentholder has 4 pages, so while using limit=2 there are 2 pages, which is working as expected. Next I try to give the 1,2, next appearing. Using this: echo $pagination = $documentHolder->renderPage(); I get an array to string conversion message and no pageitems. Using this: echo $documentHolder->render() Theres no error and the pageitems are showing up, but if I try to page to page 2 PW tries to open /?page=2 and fetches the same items as on default/page1. Where is my mistake? Thanks Harri Link to comment Share on other sites More sharing options...
LostKobrakai Posted December 8, 2015 Share Posted December 8, 2015 renderPager() ? Edit: And you need to enable pagination for the template you're adding the pagination to and not the templates you want to paginate. 1 Link to comment Share on other sites More sharing options...
h4r4ld Posted December 8, 2015 Author Share Posted December 8, 2015 renderPager() should be correct -> https://processwire.com/api/modules/markup-pager-nav/ Thanks for that hint, got it working now. How about using 2 paginations for different tables on one page? For example, I have a landingpage showing the newest documents, newest users, ... now I would like to add pagination to every table of this. Is this possible or do I allways page every overview to page2 if I click on any of those /page2 links? Link to comment Share on other sites More sharing options...
LostKobrakai Posted December 8, 2015 Share Posted December 8, 2015 Your code did miss the r, that's why I asked. Multiple paginations are doable, but you need to make use of the getVars setting and manage the start position of both find calls on your own. function pageStart($limit){ $limit = (int) $limit; if($input->pageNum === 1 || $limit < 1){ return 0; } return ($input->pageNum - 1) * $limit; } $limit = 15; $first = $pages->find("…, limit=$limit, start=" . ($input->get->first ? pageStart($limit) : 0); // Will be merged to form getVars // If you don't otherwise use the feature to ship e.g. filter settings to paginated pages // you could also directly manipulate the getVars via the pager settings. $input->whitelist("first", 1); // generate pagination 1 $limit = 12; $second = $pages->find("…, limit=$limit, start=" . ($input->get->second ? pageStart($limit) : 0); $input->whitelist("second", 1); $input->whitelist("first", 0); // generate pagination 2 4 Link to comment Share on other sites More sharing options...
h4r4ld Posted December 8, 2015 Author Share Posted December 8, 2015 Thanks for the example, I'll try and refer back if I went into trouble (which will happen for sure ) And, yeah, you got me with that r, after adding it, it works like expected. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now