ryan

PW 3.0.95 – Core updates

Recommended Posts

This week we take a look at something really cool we added a few months ago but haven’t told you about yet: owner selectors. We also take a brief look at what’s new in ProcessWire 3.0.95 and and the status of our next master version, which is just about ready!

https://processwire.com/blog/posts/processwire-3.0.95-core-updates/

  • Like 17
  • Thanks 3

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Cool  stuff @ryan!

Are there any chances this could be implemented for Table and TableRows? Would be great to have it there too.

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.