ProcessWire Weekly #316

In the 316th issue of ProcessWire Weekly we're going to check out the latest core updates, introduce a couple of new third party modules, and check out the website of a very interesting German online event. Read on!

Welcome to the latest issue of ProcessWire Weekly. This week we've got plenty of core updates to introduce, though they are mostly stability and debuggability enhancing ones. This means that there's not a whole lot of new stuff for developers and content editors, but we do have some highlights that might interest our tech-savvy readers.

In other news we're going to take a closer look at a couple of new third party modules: Cacheable Placeholers and AdoptDefaultsFromParents. The latter one has actually been around for years already, but this is another gem that only just appeared on our radar.

Finally, last but not least, we've got a very interesting new site of the week to share. This one was developed by blaueQuelle for a German conference focused on resilience — stay tuned for more details on this as well!

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: ProcesWire 3.0.158

The focus of this week's core updates has been on improving the overall quality of the core, particularly when it comes to the SQL queries performed behind the scenes and the stability of our built-in multi-instance support.

As Ryan mentions in his weekly update a lot of this is probably technical enough not to be very interesting to most of our readers, but here are a few potentially interesting highlights anyway:

  • Wire derived classes now implement a new method wired(), which gets called by when the object is "wired" to a specific ProcessWire instance. This can be used as a multi-instance safe alternative to __construct() when API variables are needed.
  • New additions to Debug::timer() include additional configuration settings for time formats etc. and a new method Debug::getAll() that returns all active timers.
  • New method DatabaseQuery::getDebugQuery() returns the query with the bind params populated. This is closely related to the recent internal database query updates and only intended for debugging purposes.
  • When fetching Page parents you can now pass boolean true as the sole argument ($page->parents(true)) to get parent pages in reverse order.

There were other, mostly minor updates as well — for full details check out the GitHub commit log. The key takeaway from this is that while the updates made past few weeks may not be appear particularly interesting for the majority of ProcessWire developers, they're essential for the longevity of the core itself.

New module: Cacheable Placeholders

Cacheable Placeholders is a new module by Moritz L'Hoest. This module was developed to resolve a rather common issue: once you're caching a piece of markup — whether a full page, or just a part of it — you can no longer utilize dynamic content generated with code, pulled from the $user API variable, etc.

Behind the scenes the Cacheable Placeholders module hooks into Page::render() and replaces found placeholder tokens ({{{token}}} where the delimiters are configurable) with their dynamic counterparts. In order to define those dynamic counterparts, you can in turn hook into the CachePlaceholders::getTokens() method:

// site/ready.php
wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) {
    $tokens = $e->return;
    $tokens['greeting'] = [
        'callback' => function (array $tokenData) {
            return ucfirst(wire('user')->name);
        }
    ];
    $e->return = $tokens;
});

That's the most basic example anyway — you can also use this module manually in case you want to use it for something like the content cached via the $cache API variable, it has support for CSRF tokens built-in, tokens can have their own parameters, and so on.

There's an extensive README file at the Cacheable Placeholders GitHub repository, so be sure to check it out for details. Big thanks to Moritz for yet another useful contribution. This module has a lot of potential, and the detailed docs are a welcome addition!

New module: AdoptDefaultsFromParents

AdoptDefaultsFromParents is a module by Steffen Henschel that we've never had the chance to feature here before, even though it's been out there for years now. Anyway, what this module does is that — as the name suggests — it automatically populates specified values for new pages from their parent parents.

In order to get this module up and running, you need to start by configuring the fields from which values are inherited — or adopted, using the terminology of this module — and the templates from which those values can be pulled from via module settings. Once this is done, every time you create a new page under a parent with one of your predefined templates, that new page will inherit specified field values from its parent.

Nice and simple, yet I for one can admit that I've built something similar on a case-by-case basis way more than once. As such, bundling this feature into a reusable module seems like a logical move indeed.

Big thanks to Steffen Henschel for developing this module. Another great idea packaged into a module. Great stuff!

Site of the week: Resilienz-Kongress

Our latest site of the week belongs to Resilienz-Kongress — a free German online event focusing on the topic of resilience, taking place between 29.5.-3.6.2020.

Hosted by Sebastian Mauritz and blauQuelle, the event has a long list of expert speakers, ranging from coaches and entrepreneurs to researchers, psychologists, and psychotherapists. Participants can register via the site, and will then receive a daily email with a link to the conference room for the day for the duration of the event.

The Resilienz-Kongress website is a one-pager, albeit a pretty complex one: all the info is on a single page, divided neatly into sections, collapsible accordions, and modal screens. Overall the site is fun browse, and while this may not be the most visually striking project we've featured here, the design is well thought out and makes the information quick and easy to grasp.

There's a lot of behind the scenes information on this project at the Resilienz-Kongress showcase forum thread, so definitely check that one out as well, but here's a short list of some technical highlights:

  • Powered by ProcessWire 3.0.155+ and reinforced by various third party modules, including ProCache, ProFields (RepeaterMatrix), PrivacyWire, and Seo Maestro.
  • The front-end makes use of the CodyFrame UI Framework
  • E-Commerce API from CopeCart.
  • Build and deploy process involving Plesk Onyx hosting setup, Git, Node, Yarn, Gulp, PostCSS, Autoprefixer, and custom-built tools for moving between local/stage/live environments.

Again, be sure to check out the showcase forum thread for more details. Big thanks to Joshua of blaueQuelle for sharing this project with us, and our congratulations for Resilienz-Kongress for their new site — and all the best to the congress itself!

Stay tuned for our next issue

That's all for the 316th issue of ProcessWire Weekly. We'll be back with more news, updates, and content Saturday, 6th of June. 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 1 comment:

savaş on Thursday 4th of June 2020 19:37 pm

processwire is great job

Post a comment