ProcessWire Weekly #311

In the 311th issue of ProcessWire Weekly we're going to talk a bit about the latest dev versions of ProcessWire, introduce a couple of new third party modules, and more. Read on!

Welcome to the latest issue of ProcessWire Weekly! This week we'll summarize the post Ryan just wrote in the processwire.com blog introducing ProcessWire,3.0.154 and 3.0.155. Additionally, we're going to introduce two new third party modules: RockBirthday by Bernhard Baumrock, and Custom Paths by Robin Sallis.

Our latest site of the week belongs to a resort and spa located at Napa Valley: Carneros Resort and Spa. Their new website — which we'll introduce in more detail in just a bit — was skillfully crafted by Zambezi Search Marketing, LLC.

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.154 and 3.0.155

This week in the processwire.com blog Ryan walks us through the last two dev versions of ProcessWire: 3.0.154 and 3.0.155. Some of the features covered by this week's blog post we've already mentioned in the Weekly, but there are also some brand-new additions:

We'll leave the in depth walkthrough for Ryan, but just to give you a basic idea about what to expect from the all-new core additions this week:

  • $input->urlSegment() has gained quite a few new features. For an example you can now pass in negative index value (to get a segment from the end of the URL), use wildcards or regex to match segments, and use "=foo" or "foo=" syntax to get the segment that preceded by or succeeded by "foo".
  • $input->canonicalUrl() is a new way to get a canonical ("preferred") URL for the current page. This can be configured by passing it an array of options, which in turn allows you to specify exactly which parts — such as URL segments or page numbers — you consider canonical, which protocol you want to prioritize, etc.

That's all for the core updates section this week. As mentioned above you can find a very comprehensive introduction to these new features and all their variations and options from this week's blog post, so be sure to check it out as well. Thanks!

New module: RockBirthday

Sometimes we all need a little pick-me-up, and that's exactly what this module delivers: RockBirthday, the latest creation by Bernhard Baumrock, is a little module that pops up a "happy birthday" message to users on, or near, their birthday.

RockBirthday is quite a lightweight module, implemented in less than a hundred lines of code — a good reminder of how simple developing modules for ProcessWire can be. Now, there's actually no GUI whatsoever for this nodule, but you can easily configure and init it via hook functions placed in the /site/init.php file:

// Define how long after the birthday message should be displayed
$wire->addHookAfter("RockBirthday::setConfig", function($event) {
    $event->object->maxDays = 14; // (this is the default value)
});

// Get date of birth for current user (return value as an integer)
$wire->addHookAfter("RockBirthday::getBirthdate", function($event) {
    $user = $this->user;
    $event->return = $user->getUnformatted('your_birthdate_field');
});

// Define markup for the birthday message
$wire->addHookAfter("RockBirthday::getMarkup", function($event) {
    $user = $this->user;
    $html = "<h1>Happy Birthday, {$user->name}!</h1>";
    $event->return = "<script>vex.open({unsafeContent: \"$html\"});</script>";
});

... and that's it. Not particularly difficult, right? Also, thanks to the no-nonsense hook-only approach, the birthday message is completely customizable. Custom message in any language? Easy. Prefer to display a GIF animation instead? Can do!

Thanks to Bernhard for building and sharing this fun little module with us! It's a fun little tool, and quite versatile; I can already think of a few non-birthday-related use cases for it as well.

New module: Custom Paths

Another new third party module for this week is Custom Paths, developed by Robin Sallis. There's a comprehensive introduction to this module available at the Custom Paths support forum thread, but to summarize:

  • This module adds a field called custom_path, which — if added to the applicable template and populated for a specific page — overrides ProcessWire's native path and URL properties.
  • You can specificy any value for the custom path, as long as it's compatible with the URL settings defined in ProcessWire's $config and your site's .htaccess file.
  • Custom paths support URL segments and page numbers, and the PagePathHistory module (if installed) will also know how to handle them.
  • Finally, an important point regarding native and custom path precedence: custom paths will overwrite any native path if they overlap. In fact you could even override the root page (/) with a custom path.
Custom Paths module in action. Screenshot by Robin Sallis.

By default the custom path field is placed after the native name field, which gives a nice "built-in" feel to it, but this feature can be disabled via the module settings if you prefer to place the field manually instead. You could also hide the custom path field entirely, populating it automatically when the page is saved; check the support thread for some ready-for-use hook examples.

Big thanks to Robin for another very useful module — I for one can't wait to give this module a try in a future project!

Site of the week: Carneros Resort and Spa

Our latest site of the week belongs to Carneros Resort and Spa — a luxury resort in Napa Valley, California.

Although at the time of this writing the venue is sadly temporarily shut down due to the worldwide situation, Carneros does look like an amazing location for a little off time, or even hosting events. They've got all sorts of cottages and houses, a spa, various dining options, and of course a beautiful location with unbeatable natural views.

The site of Carneros Resort and Spa was designed and developed by Zambezi Search Marketing, LLC, and boasts a very stylish and modern design, complete with varying collection of different content blocks, high quality photographs, and some very interesting typographic effects. Transitions and animations have been thrown in to liven things up just a bit, and the end result is nothing short of stunning.

The front-end of this site is based on the Uikit front-end framework, and behind the scenes we could spot at least a couple of popular third party ProcessWire modules: ProCache and FormBuilder, both developed by Ryan Cramer. The site is served via a Cloudflare proxy, and a number of other steps have apparently also been taken in order to guarantee proper performance — including, but not limited to, inlining a notable block of critical CSS.

Big thanks to the folks at Zambezi Search Marketing for sharing this project with us, and our congratulations to Carneros Resort and Spa for their new website — very impressive!

Stay tuned for our next issue

That's all for the 311th issue of ProcessWire Weekly. We'll be back with more news, updates, and content Saturday, 2nd 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!

This post has 2 comments:

HMCB on Saturday 2nd of May 2020 0:17 am

Does the birthday module provide the code needed to display it on the front end?

teppo on Saturday 2nd of May 2020 10:24 am

Hey HMCB!

No, not at the moment. RockBirthday is currently tied to the admin theme framework. You could use RockBirthday::getMarkup() to get the markup itself, but you'd still have to perform birthday calculations on your own, so it's kind of pointless.

If you're interested in this feature, I'd suggest writing to Bernhard via the support forum: https://processwire.com/talk/topic/23513-rockbirthday-show-a-happy-birthday-popup-to-users/.

Post a comment