ProcessWire Weekly #416

In the 416th issue of ProcessWire Weekly we'll check out ProcessWire 3.0.199, feature a new recipe of the week, and more. Read on!

Welcome to the latest issue of ProcessWire Weekly. After last week's shorter-than-usual issue, this week we're back to our usual content. In this issue we'll take a quick look at the latest core updates, feature a new weekly ProcessWire recipe, and check out a very nice new site of the week.

Thanks to all of our readers for being here with us again, and as always, any feedback is most welcome – please don't hesitate to drop us a line if there's anything in your mind you'd like to share with us. Enjoy our latest issue and have a great weekend!

Latest core updates: ProcessWire 3.0.199

In this week's update at the support forum Ryan talks about ProcessWire 3.0.199 (dev). This version — which could be our last development release before a new stable — is again primarily focused on resolving any outstanding issues:

  • Fix for issue #1160 where the $sanitizer->pagePathName() was not behaving consistently with $sanitizer->pageName().
  • Fix for issue #1536 where non-ASCII characters in field tags could cause errors in the field editor.
  • Fix for issue #1550 where $pages->getByPath('/path/to/page') could sometimes get confused and return unexpected results in multi-language setups.
  • Fix for issue #1560 where rebuilt image variations didn't use all detected options.
  • Fix for issue #1561 where non-superusers could run into permissions issues while editing file fields within Repeater items with AJAX enabled.

This version also contains additional updates for automatic image rotation based on EXIF data (resolving an issue where front-end resize wasn't handling orientation info correctly) and further improves ProcessWire's PHP 8.1 compatibility.

If you'd like to help test the dev branch before stable master/main version is released, this would be a great time for that. 3.0.200 will likely be our next stable release, and it could be out as soon as in the next week or two. Let us know if you notice any issues.

That's all for our core updates section this week. Be sure to also check out the weekly update from Ryan. Thanks!

Recipe of the week: finding content based on properties of a page that references said content

This week we'll feature a recipe of the week that makes use of a particular core feature that has many use cases, but isn't — at least in our experience — exactly well-known: the ability to find pages based on some aspect of a page referencing them.

This recipe was inspired by a recent forum post covering one of the use cases for said feature, so hat tip to Robin for bringing it up!

The problem

We're all familiar with the way selectors work when finding pages: specify fields and/or properties, operators, and values you want those pages to match, and you'll get page(s) in return. So far so good. But what if the property is not of the page itself, but rather a page referencing it via a PageTable, Page Reference, or Repeater field?

For an example let's say that we have "member" pages, each of which has a "bills" field (PageTable), and we need a list of unpaid bills for all members who have joined before current year. Let's also say that in this case bills are not direct children of members, which means that simple parent query is not an option.

The solution

While we could find the members that joined last year, iterate over them, and then look for unpaid bills, that would get kind of verbose, and wouldn't be great for performance. For one this approach would involve loading a whole lot of unnecessary content, which is always something that we'd rather avoid.

Luckily there's a straightforward solution: owner queries, added in ProcessWire 3.0.95. Owner queries can be used with any page-referencing field, including PageTable and Repeater. Here's an example of what a selector for our use case might look like:

$bills = $pages->find('template=bill, paid=0, bills.owner.joined<first day of january');

This query will return all pages matching following criteria:

  • Template of the page is "bill"
  • Value of the "paid" field is 0, in this case meaning that the bill is unpaid
  • Page is selected in the "bills" field on a page with "joined" value before this year

In other words this should get us exactly what we were looking for: unpaid bills of those members who joined before current year. And since it's a single query, it should be fast — though obviously if you're dealing with a lot of data, you'll want to add a limit and perhaps use $pages->findMany() instead of $pages->find().

The "owner" selector is not one that most of us come across too often, but when there is a use case for it, it's a downright brilliant API feature. And since owner works with page reference and repeater fields as well, it's quite versatile.

That's all for our recipe of the week. Hope you found it useful, and please let us know if you've got suggestions for future recipes — or problems that need solving! — and we'd be happy to feature them in our future issues.

Site of the week: Triasima

Our latest site of the week belongs to Triasima, a portfolio management company based in Montreal, Canada.

Triasima has been around for more than 20 years, and they serve clients in Canada and the United States. Their promise is to invest assets of institutional as well as high net worth private customers in a responsible manner, following what they describe as the Three-Pillar Approach.

The Triasima website was a co-project by Contractuelle and Spiria, the latter of whom worked as the contractor responsible for the site integration. In addition to a very nice design and plenty of quality content, this site also features area-specific site versions, and two language versions.

The front-end of this site appears to be custom built, without the help of a full-blown front-end framework, and as for third party ProcessWire modules, the ones we could spot are commercial Pro modules ProCache and FormBuilder. You can find additional details about the implementation from the Triasima website case story at the support forum, including a page builder GUI screenshot, so be sure to check it out as well.

Big thanks to the folks at Spiria for sharing this project with us, and our congratulations to both the team behind the site and the client — the Triasima website is a pleasure to use and looks absolutely stunning, so congratulations for a job well done!

Stay tuned for our next issue

That's it for the 416th issue of ProcessWire Weekly. We'll be back with more news, updates, and content Saturday, 7th of May. As always, ProcessWire newsletter subscribers will get our updates a few days later.

Thanks for staying with us, once again. Hope you've had a great and productive week, and don't forget to check out the ProcessWire forums for more interesting topics. Until next week, happy hacking with ProcessWire!

Post a comment