adrian Posted March 13, 2013 Posted March 13, 2013 Is this possible? I am trying to combine results of more than one $pages->find. I know I could append the results of one to the pagearray of the other, but I want to be able to apply a limit to the combined results of both, sorted by modified, before returning the results. Thanks
adrian Posted March 13, 2013 Author Posted March 13, 2013 Thanks - I guess it's not a big deal to do it that way. I think I am just so used to using SQL to do most of the work first that the idea of returning so many results just to later throw them out seems weird
WillyC Posted March 13, 2013 Posted March 13, 2013 $select1 = 'template=bluskchug, ...whtevr u want'; $select2 = 'template=chishpahjung, ...whaevr u.like'; $select3 = 'sort=...you say, limit=10'; $select3 .= ", id="; // leav.thi s $findre = new PageFinder(); $res1 = $findre->find(new Selectors($select1)); $res2 = $findre->find(new Selectors($select2)); foreach(array_merge($res1, $res2) as $hi) $select3 .= "$hi[id]|" $res3 = $findre->find(new Selectors(rtrim($select3, '|')); $ids = array(); foreach($res3 as $hi) $ids[] = $hi['id']; $yopages = $pages->getById($ids); or.u jus.use sql.queery 2
Soma Posted March 13, 2013 Posted March 13, 2013 Maybe also look at this example here https://gist.github.com/somatonic/3558974
adrian Posted March 13, 2013 Author Posted March 13, 2013 Thank you both for those ideas - I didn't really know about the PageFinder class, but just did some more reading about it here (http://processwire.com/talk/topic/1227-lazy-loading-of-pages/?p=10907). Seems like that could come in handy for sure. I might also just start using SQL in cases like this.
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