Peter Knight Posted January 30, 2019 Share Posted January 30, 2019 I have a selector which is pretty simple and just fetches a series of pages except for the current page. 1,2,3,4,5,6,7 When you're on page 1, the output is 2,3,4,5,6,7 When you're on page 2, the output is 1,3,4,5,6,7 $services=$pages->find("template=a-practice-area, id!=$page, sort=sort "); foreach($services as $service) { echo " <div>... Currently, the array (is that what it's called? starts from the first item (service) in the tree and continues. I'd now like to start the array from the next item in the array instead always starting at the first. IE if you were on page 2, the output is 3,4,5,6 IE if you were on page 4, the output is 5,6,7 Looking at the docs, a selector called 'start' is mentioned. Quote That selector tells ProcessWire to return 50 (or fewer) results. The starting result is always the first, unless you use the "start" reserved word, i.e. start=50, limit=50 2 I think this is what I need and have tried the following to no avail <?php $services=$pages->find("template=a-practice-area, id!=$page, sort=sort, start=$page"); Any tips? Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 30, 2019 Share Posted January 30, 2019 https://processwire.com/api/ref/page/next-all/ / https://processwire.com/api/ref/page/prev-all/ 3 Link to comment Share on other sites More sharing options...
ottogal Posted January 30, 2019 Share Posted January 30, 2019 Citing from the linked doc pages: Quote Returns all matching pages after this one, or integer if $count option specified. Here "$count option" should read "getQty" option, shouldn't it? Link to comment Share on other sites More sharing options...
Peter Knight Posted January 31, 2019 Author Share Posted January 31, 2019 16 hours ago, LostKobrakai said: https://processwire.com/api/ref/page/next-all/ / https://processwire.com/api/ref/page/prev-all/ Thanks for this. It looks promising but seems to apply to page instead of pages. Is there a pages equivalent? Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 31, 2019 Share Posted January 31, 2019 Why would there if you need a "current" page to be able to do all of that? Link to comment Share on other sites More sharing options...
Peter Knight Posted January 31, 2019 Author Share Posted January 31, 2019 1 hour ago, LostKobrakai said: Why would there if you need a "current" page to be able to do all of that? You're right - thank you. So I adapted my code to use page instead of pages and this modfied version works $items = $page->nextAll('template=a-practice-area'); foreach($items as $item) { echo " IE if you were on page 4, the output is5,6,7 Is there a method to restart the array after it reaches the end so that the output is 5,6,7,1,2,3,4 Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 31, 2019 Share Posted January 31, 2019 I'd simply combine the two options. 2 Link to comment Share on other sites More sharing options...
Peter Knight Posted January 31, 2019 Author Share Posted January 31, 2019 3 minutes ago, LostKobrakai said: I'd simply combine the two options. It doubles up on my code but certainly works. Thanks ? Link to comment Share on other sites More sharing options...
Peter Knight Posted January 31, 2019 Author Share Posted January 31, 2019 Actually I spoke too soon. Combining the two gives me 5,6,7(and then) 4,3,2,1 What I'd like to do is 5,6,7,1,2,3,4 Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 31, 2019 Share Posted January 31, 2019 Reverse the second part? 2 Link to comment Share on other sites More sharing options...
Peter Knight Posted January 31, 2019 Author Share Posted January 31, 2019 53 minutes ago, LostKobrakai said: Reverse the second part? After trying various sort and reverse options, I saw you post, tried again and it's perfect now ? $does2 = $page->prevAll("template=a-practice-area")->reverse(); foreach($does2 as $do2) 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