ProcessWire Weekly #354

In the 354th issue of ProcessWire Weekly we're going to check out the latest core updates, properly introduce the ProcessCKInlineComplete module, and dig into a brand new site of the week. Read on!

Welcome to the latest issue of ProcessWire Weekly. In this issue we're going to cover the latest core updates and summarise a tutorial Ryan posted with his latest update via the support forum. Although the core version remains the same as last week, 3.0.172, there have still been some updates that we'll gladly share with you folks in a bit.

In other news we're finally going to take a closer look at the third party module known as ProcessCKInlineComplete (or Autocomplete for CKEditor), and in our site of the week section we'll highlight the portfolio of traveller and photographer Abe Kogan.

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

In his latest weekly update Ryan summarises the core development work he's done this week, and also digs a bit deeper into one particular topic: custom after-save actions in the Page editor. Here we'll talk a bit about the core updates, and then summarise what that latter part means in practice.

Quick rundown of core updates for the week

The core updates for the week — which you can check out from the weekly commit log — are as follows:

  • Fix for a LazyCron bug introduced in 3.0.172. The module had ConfigurableModule interface unintentionally applied to it, resulting in errors in the admin panel.
  • Support for "preload" modules, which are loaded before all other modules. This feature provides a solution to earlier request for a way to load Tracy Debugger before other modules.
  • Documentation updates for the advanced mode configuration setting, detailing the features enabled by this switch.
  • Core WireMail class and ProcessForgotPassword module were updated to look for default outbound (from) email address from config settings even if it was earlier cleared by a third party module.

Custom after-save actions in the Page editor

When we talk about after-save actions, what we mean are those handy little shortcuts you'll find from the page editor save button: "Save + Exit", "Save + Add New", and so on. One of the open requests in the processwire-requests repository was for the ability to define custom after save actions — which, as it happens, has since been implemented in the core, but not formally documented.

In his post Ryan provides us with a little tutorial for adding your own custom actions. We won't rephrase the whole tutorila here, but the gist of it is that you'll first want to hook into the ProcessPageEdit::getSubmitActions() method to add your action to the button, and then hook to ProcessPageEdit::processSubmitAction() in order to process your newly added action:

// add a new action called "hello"
$wire->addHookAfter('ProcessPageEdit::getSubmitActions', function($event) {
    $actions = $event->return;
    $actions['hello'] = [
        'value' => 'hello',
        'icon' => 'hand-spock-o',
        'label' => '%s + Say Hello',
    ];
    $event->return = $actions;
});

// process the "hello" action
$wire->addHookAfter('ProcessPageEdit::processSubmitAction', function($event) {
    $action = $event->arguments(0);
    $page = $process->getPage();
    if ($action === 'hello') {
        $notice = new NoticeWarning("Hello! You edited {$page->path}");
        $notice->icon = 'hand-spock-o';
        $event->notices->add($notice);
    }
});

As you can see, it's actually pretty simple to add your own actions. The example above is not particularly useful, but you can find more useful examples from the weekly post, and you can perhaps think of a few of your examples own as well.

That's it for our core updates section this week. For more details, be sure to check out the weekly update from Ryan. Thanks!

New module: ProcessCKInlineComplete

Although not new as in something that was just released, ProcessCKInlineComplete is a third party module that we haven't yet had a chance to dig in properly. This module was developed by BitPoet and also goes by the name Autocomplete for CKEditor, and it was in fact briefly mentioned in our issue #225 way back in 2018.

In a nutshell ProcessCKInlineComplete adds an autocomplete search and simple dialog for embedding items within CKEditor field. These items can be pretty much anything: the module comes bundled with "actions" for embedding links to user pages or Hanna Code tags, but it's quite simple to extend the module with your own custom actions.

ProcessCKInlineAcions demonstration using both user and Hanna Code actions as examples.

ProcessCKInlineComplete is tested with ProcessWire 3 and has been around for a while, but it's labeled "beta" and hasn't been added to our modules directory, so extra caution is recommended. That being said: be sure to give it a try if you come across a use case for an autocomplete embed feature.

Big thanks to BitPoet for sharing this module with us!

Stay tuned for our next issue

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

Robin S on Saturday 20th of February 2021 23:16 pm

Just a small clarification regarding the after-save action GitHub request... the post reads as if the request was made for something that was already supported in the core. But the request dates from March 2018 and requested feature was added in October 2019. I'm not sure if Ryan added the feature in response to the request and forgot to mention it in the GitHub request thread, or if he made the change of his own accord not knowing about the request.

teppo on Thursday 25th of February 2021 20:15 pm

Hey Robin — thanks, I've clarified the text above!

Post a comment