ProcessWire Weekly #273

In the 273rd issue of ProcessWire Weekly we'll check out ProcessWire 3.0.137, introduce the Uikit3 Minimal Profile, reintroduce AdminBar version 2, and of course check out a brand new site of the week. Read on!

Welcome to the latest issue of ProcessWire Weekly! This week we're going to introduce ProcessWire 3.0.137, which contains updates to a number of core classes, and adds new way for attaching a single hook handler into multiple hookable methods on one go.

In other news we've got the Uikit3 Minimal Profile, and we're also going to take a closer look at the newly released version 2 of the AdminBar module. Finally, we've got our site of the week, which was developed by blaueQuelle Werbeagentur for a German company called DINO Gewerbepartner.

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.137

In this week's processwire.com blog post Ryan takes the time to introduce the latest of our dev releases, ProcessWire 3.0.137. This version includes a number of fixes, plenty of housekeeping updates for core classes, and also one really handy new feature: hooking multiple methods at once.

Hooking multiple methods at once

Before 3.0.137 if you wanted to attach a single hook handling method into multiple hookable methods, you could do that, but you had to call addHook multiple times – once for each hookable method. As of the latest dev release you can now specify multiple comma-separated methods for any addHook call:

// hook into Page::viewable() and Page::editable() in one go
$wire->addHookAfter('Page::viewable, Page::editable', function($event) {
   $event->message("Triggered the hook on {$event->method}");
});

You can use this new syntax in the context of specific objects as well – $pages->addHookBefore('saveReady, saved'), function(HookEvent $event) { ... } – and it works for all of the built-in addHook methods: addHook, addHookBefore, addHookAfter, addHookProperty, and addHookMethod.

Mirroring assets from one environment to another

In this week's post Ryan also shares a really neat trick for mirroring site assets, i.e. files and images, from one environment to another – e.g. from production to development – by automatically downloading them when requested. What's really cool is that this is actually a really simple concept – here's all the required code in its entirety:

$wire->addHookAfter('Pagefile::url, Pagefile::filename', function($event) {

    $config = $event->wire('config');
    $file = $event->return;

    if($event->method == 'url') {
        // convert url to disk path
        $file = $config->paths->root . substr($file, strlen($config->urls->root));
    }

    if(!file_exists($file)) {
        // download file from source if it doesn't exist here
        $src = 'https://domain.com/site/assets/files/';
        $url = str_replace($config->paths->files, $src, $file);
        $http = new WireHttp();
        $http->download($url, $file);
    }
});

The general idea here is to fetch assets when requested from the production site – or an external development version, etc. You can read more about this method, and how and what for it can be used, from Ryan's weekly blog post.

For more details about this week's updates, as well as a brief summary regarding last week's core updates and an in-depth introduction to the just-in-time asset migration script above, be sure to read the latest post at the processwire.com blog. Thanks!

New site profile: Uikit3 / Minimal Profile

Uikit3 / Minimal Profile is a new site profile developed by rafaoski. It's based on the Uikit front-end framework and utilises a number of quite recent additions to the core, which is also why it requires at least version 3.0.127 of ProcessWire. Here are some of the other features you'll find in this site profile:

  • The site profile was built with multi-language support in mind.
  • The options page makes use of the unique status added in ProcessWire 3.0.127.
  • This site profile utilises the Markup Regions output strategy, and also has the Functions API enabled.
  • Settings are managed with the Function API setting() function added in ProcessWire 3.0.119.
  • Among the templates and other site features included in this profile are regular home and basic content page, search feature, blog, an authors page, and a monthly archive for posts.

A full list of features is available at the modules directory entry for Uiki3 / Minimal Profile, a demo site for this profile can be found from https://proc-profiles.tk/uk3-min/, and if you'd like to give the site profile a try or take a closer look at the source code it's available in its entirety at the site-uk3-minimal GitHub repository.

Big thanks to rafaoski for sharing this site profile with us!

Reintroducing the AdminBar module

AdminBar is one of the oldest third party modules for ProcessWire, dating back to 2011. This module was originally developed by Antti Peisa, and it's now maintained by Teppo Koivula. The reason we're re-introducing the module here is that it has gone through pretty big updates in the past couple of weeks, going from major version 1.x to 2.x.

For those who are not yet familiar with this module, it's actually quite simple: it adds an "admin bar" to the top of public side of your site if you're logged in and are a superuser or have the "adminbar" permission. From this admin bar you can find features such as browse and edit (current page), add new page, admin (link), and logout (link).

Here's what that admin bar looks by default in the new version of the module. "Edit" opens a modal – or slide down – screen with page edit form. It can be configured to link to the Admin instead, though.

The new version 2 of this module provides extended capabilities for hooking into and modifying the built-in features, as well as customising it with new themes and adding entirely new links or other features. There are three built-in themes, with the default one – "uikit" – being a loose imitation of the top bar of the Uikit Admin Theme.

If you've been using AdminBar before, know that AdminBar 2 is indeed a major update, and requires ProcessWire 3.x and PHP 7.1.0 (or newer). Much of the internals have been updated, so old custom styles etc. will also no longer work as expected.

Feel free to give this module a try – you can install it via the built-in module installer in Admin, by downloading or cloning its code from the AdminBar GitHub repository, or by Composer (composer require teppokoivula/admin-bar in site root or the site directory).

Site of the week: DINO Gewerbepartner

Our latest site of the week belongs to a German company known as DINO Gewerbepartner.

Founded in 1995 by Dino M. Wolter in the city of Göttingen, DINO provides a number of advertising and promotion related products and services for their customers – promotional items, advertising attachments, work clothing, vehicle lettering, shop window lettering, and more.

Developed by blaueQuelle Werbeagentur, the DINO website features a beautiful and elegant design, and plenty of variance in terms of content. It appears that the content on this page is constructed using a page builder type approach, and as such there are really no two exactly identical pages to be found here – instead each page is a collection of different content columns, image and personnel highlights, and other pieces of custom content.

The front-end of this site doesn't seem to use a full-featured front-end framework, but on the other hand at least parts of the site seem to be powered by the Vue.js JavaScript framework. Digging a bit deeper we were also able to spot a couple of familiar modules: FormBuilder and ProCache, two of the commercial Pro-modules developed by Ryan.

Big thanks to the folks at blaueQuelle for sharing this site with us, and congratulations to DINO Gewerbepartner for their new website. Looking really slick — great job from everyone involved in this project!

Stay tuned for our next issue

That's it for the 273rd issue of ProcessWire Weekly. We'll be back with more news, updates, and content Saturday, 10th of August. 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:

rafaoski on Monday 5th of August 2019 14:27 pm

Thanks to teppo for noticing the new page profile ... As always a great article from the world of ProcessWire ... On the other hand, the administrative AdminBar looks great !!! ... It is a pity that the AdminBar is not in the basic ProcessWire installer for the administration panel based on UIKIT3 ...

Post a comment