Jump to content

Recommended Posts

Posted (edited)

Ryan, great work, as always, on the "owner" selection! Very cool stuff!! I'm eager to use it someday! 

Edited by Sergio
grammar
  • Like 1
Posted

option 1: w/ 'owner' selector (as mentioned in blog post)

$items = $pages->find(
  "template=architect, " .
  "architects.owner.parent.name=atlanta, " .
  "architects.owner.height>1000"
);

option 2: w/o 'owner' selector (2 queries required)

$architects = new PageArray();
foreach($pages->find("template=building,height>1000,parent.name=atlanta") as $building) {
  $architects->add($building->architects);
}

option 3: w/o 'owner' selector but requires a bi-directional relationship field called 'buildings' on the 'architect' template (using the bi-directional approach or possibly PagefieldPairs, or ConnectPageFields):

$pages->find("parent=/architects/,template=architect,buildings.parent.name=atlanta,buildings.height>1000");

Hopefully that de-mystifies it.  I come across this brain twister once in a while.

  • Like 5
Posted
13 hours ago, Jonathan Lahijani said:

I come across this brain twister once in a while.

Know exactly what you mean! I had something similar a couple of years ago and did find a kinda solution, but was never happy with it. Just hope I remember about this next time the need arises.

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
  • Recently Browsing   0 members

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