OLSA Posted September 26, 2015 Share Posted September 26, 2015 Hello for all, Please before read, just one note here - in problem description I use word "article" for child pages. I have category "News" with about 700 articles. Because on every News page are list with 5 articles, pagination goes from 1 to 141 pages. On sidebar I render "widget" where are 3 articles from another category ("Projects"). Projects articles: a, b, c, d, e, f, g, h, i, j, k... Problem: News page 1, widget Project shows: a, b, c - correct News page 2, widget Project shows: d, e, f - wrong (need to show a, b, c) News page 3, widget Project shows: g, h, i - wrong (need to show a, b, c) And same principle on other pages... Widget render articles using $pages->find call: $items = $pages->find("parent={$page->parent_page->id}, limit={$page->num_of_articles}, sort=-date_end"); Any help? Thanks. Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 26, 2015 Share Posted September 26, 2015 You're using limit in both selectors and pagination does set the start value automatically, if there's non present. That's why both finds do get paginated. Add start=0 to the widget selector and it works. 2 Link to comment Share on other sites More sharing options...
OLSA Posted September 26, 2015 Author Share Posted September 26, 2015 Thanks LostKobrakai! There is still too many PW secrets for me, read almost all documentation but couldn't find this what you write here. I will remember this: Pagination can make "troubles" because it can be in correlation with other MySQL queries ($pages->find) on the same page. Thank you! EDIT 27.09.2015: Thanks @SiNNuT I find where Ryan write about this (Avoiding pagination pitfalls, 25.09.2015.): If you have other find() operations with "limit=n" selectors occurring elsewhere during that same request, ProcessWire will try to paginate them too. That may not be what you want. Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 27, 2015 Share Posted September 27, 2015 The starting result is always the first, unless you use the "start" reserved word, i.e. start=50, limit=50 … If you are using a limit selector with pages, and your template has page-numbers turned on, ProcessWire will automatically set the "start" selector according to the current page number. So when it comes to pagination, you don't usually have to think about anything other than the "limit" selector. See here: http://processwire.com/api/selectors/#limit 1 Link to comment Share on other sites More sharing options...
SiNNuT Posted September 27, 2015 Share Posted September 27, 2015 It's not so much 'troubles', just something to be aware of. Incidentally Ryan has a quite nice write-up about pagination (and some other stuff) in this weeks blog post. https://processwire.com/blog/posts/processwire-2.6.18-updates-pagination-and-seo/ 2 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