Jump to content

Combining queries


caribou
 Share

Recommended Posts

Edit: In other news, I've discovered that a foolproof way to find obvious code errors is to post a problem here. Then I immediately see what I did wrong, but can't delete the post...

For the record, double quotes in the find, and I used just template instead of $page->template further up the page.

---

Hello again, helpful forum members. I am trying to create a complex query, but not having any luck. In this example, I'm looking for pages with a specific template (could have any parent) *and* pages with a specific parent (could have any template). I understand the or operator doesn't work within find yet, so is there a different way to stack and combine queries?

I've determined that this way doesn't work:

...
	$template = $pages->find('template=species');
	$children = $pages->find('has_parent=$page');
	$windows = $pages->find('id=$template|$children');	
...	

foreach ($windows as $window) {...

Thanks!

Link to comment
Share on other sites

You can use something like this:

$template = $pages->find("template=species");
$children = $pages->find("has_parent=$page");

$windows = $template->import($children);

edit: added double quotes (browsercoding is bad)

  • Like 2
Link to comment
Share on other sites

You have to change everything to double quotes:

$template = $pages->find("template=species");
$children = $pages->find("has_parent=$page");
$windows = $pages->find("id=$template|$children");
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

×
×
  • Create New...