adrian Posted March 13, 2013 Share 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 Link to comment Share on other sites More sharing options...
apeisa Posted March 13, 2013 Share Posted March 13, 2013 Combine page arrays, sort them and then cut? Link to comment Share on other sites More sharing options...
adrian Posted March 13, 2013 Author Share 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 Link to comment Share on other sites More sharing options...
WillyC Posted March 13, 2013 Share 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 Link to comment Share on other sites More sharing options...
Soma Posted March 13, 2013 Share Posted March 13, 2013 Maybe also look at this example here https://gist.github.com/somatonic/3558974 Link to comment Share on other sites More sharing options...
adrian Posted March 13, 2013 Author Share 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. 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