Gazley Posted August 23, 2012 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.
Gazley Posted August 23, 2012 Author Posted August 23, 2012 Sorry! $matches = $pages->get('/galleries/')->children("categories_selected=$category, private=0"); does the trick!
Soma Posted August 23, 2012 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
Gazley Posted August 23, 2012 Author 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
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