1063Selector Magic in ProcessWire

ProcessWire's way of selecting ("getting") child pages is usually like this:
Get all children

$events = $page->children();

This can be fine-tuned with the Selector string.
Get all children, where the date or end_date is later than today, sort the results by date.

$events = $page->children("date|end_date>today,sort=date");

This works great, by we recently had a case, where a schedule talk had to be postponed to an unknown date in the future. I left the date field in the Backend empty, we need to modify the selection string:
Get all children, where the date or end_date is later than today OR where date is empty, sort the results by date.

$events = $page->children("(date|end_date >today), (date=), sort=date");

It's beautiful, that it's just a small change in the selection string:

  • The additional parenthesis () around (date|end_date >today) and (date=) specify an OR relation. Default is AND, here it means: select children with either (date|end_date >today) OR (date=) - no date.
  • date= means that the date field is empty

Resources

1062Resetting a User Password in ProcessWire

It happens to best of us: You have an local installation of your favourite CMS - and then you can't remember the password! Login throtteling kicks in, you still can't remember it. And this being a local XAMPP installation, you can't send an email to recover the password.

Here is Ryan1 to the resuce:

You can always reset your password just by pasting this temporarily into any one of your templates, and then viewing a page that uses the template:

$u = $users->get('admin'); // or whatever your username is
$u->of(false); 
$u->pass = 'your-new-password';
$u->save();

1 Who is Ryan? Ryan Cramer is the founder and lead developer of ProcessWire.