Gazley Posted August 23, 2012 Share Posted August 23, 2012 Hi there, I have the following query: $matches = $pages->get('/galleries/')->find("categories_selected=$category, private=0"); It actually returns the categories_selected Page(s) but what I want is the page that contains the matching categories_selected, in this case, the 'album' page. BTW, categories_selected is a Page field, the overall structure is /galleries/album. Obviously, I could get a collection of none-private albums and then loop round them checking for matching categories. However, I wondered whether this could be done in a single query? Thanks. Link to comment Share on other sites More sharing options...
Gazley Posted August 23, 2012 Author Share Posted August 23, 2012 Sorry! $matches = $pages->get('/galleries/')->children("categories_selected=$category, private=0"); does the trick! Link to comment Share on other sites More sharing options...
Soma Posted August 23, 2012 Share Posted August 23, 2012 This could also work $pages->find("parent=/galleries/,categories_selected=$category, private=0"); parent= will look for direct children of /galleries/ only And to make it complete this if searching for nested children $pages->find("has_parent=galleriesID, categories_selected=$category, private=0"); 1 Link to comment Share on other sites More sharing options...
Gazley Posted August 23, 2012 Author Share Posted August 23, 2012 parent & has_parent - cool. I looked at the 'Selectors' page before posting and completely missed these two gems! Thanks for pointing them out Soma; they are a very powerful addition to the querying toolbox 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