Jump to content

Test for Page(s) but return its Parent?


Gazley
 Share

Recommended Posts

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

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");
  • Like 1
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...