ProcessWire Weekly #267

In the 267th issue of ProcessWire Weekly we're going to cover the latest changes in the development branch of ProcessWire, introduce a new module called MarkupMenu, and highlight a brand new site of the week. Read on!

Welcome to the 267th issue of ProcessWire Weekly! Hope you've had a great weekend so far, and hope you enjoy our weekly update on all things ProcessWire.

In this week's issue we're going to cover some of the updates made to the development branch of ProcessWire during the past week, introduce a new third party module called MarkupMenu, and highlight a really good looking new site of the week belonging to the employee wellbeing company Kamwell.

This issue is going to be relatively brief, but we'll be sure to have more content for you in our next issue at the end of June. In that issue we should have some interesting news regarding the weekly.pw website as well, so stay tuned for that – and until then, be sure to enjoy the (hopefully) nice summer weather!

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, and a weekly update from Ryan

This week we've continued working towards a new version, but we're not quite there yet, so the current dev branch version is still 3.0.133. We'll likely see 3.0.134 sometime next week, or at the latest the week after that.

In this week's update posted to the support forum Ryan talks a bit about this version and the coming week's development schedule, and highlights one specific feature from the coming updates: a nice little GUI update for InputfieldSelector, which basically combines the "Field" and "Field..." selections to one option supporting subfields, thus removing an extra step and improving the UX overall.

Based on the dev branch commit log for the past week, here are a few other highlights:

  • An improvement to operator extraction in Selectors class so that it doesn't potentially match non-existent operators and throw an unnecessary "unknown operator - selector value property escaped?" error message.

  • Improvements in PageFinder to handle some additional types of native field queries like partial match of parent.path (parent.path%=something), matching parent.status, and some others.

  • Some new option manipulation methods (such as optionLabel(), replaceOption(), and insertOptions()) to InputfieldSelect.module, which are also inherited by all of ProcessWire's single and multi-selection Inputfields.

One more addition included in this week's updates – introduced as part of the solution for an issue affecting login redirects on sites using two-factor authentication – is the hookable ProcessLogin::getBeforeLoginVars() method. For security reasons ProcessWire strips out most query string variables after successful login, but with this method in place it's now easy to add support for more variables on a case-by-case basis.

Check out the commit log if you want to dig deeper into this week's additions. With Ryan traveling next week it remains to be seen how much new stuff is going to end up into the core, but we'll be sure to cover those in our next weekly issue.

New module: MarkupMenu

MarkupMenu is a new markup module for ProcessWire, providing easy to use support for producing menu markup based on provided arguments. The concept is simply to render a nested list of pages matching provided rules – such as a selector string for including pages, and another for excluding pages – and then adding some additional logic on top of that.

If you've been around for a while, you're undoubtedly familiar with the Markup Simple Navigation module from Soma. MarkupMenu draws a lot of inspiration from that, but provides some additional features, and on the other hand omits a few things (xtemplates, for an example). Usage is as simple as getting an instance of the module, and running the render method with an array of options:

echo $modules->get('MarkupMenu')->render([
    'root_page' => $pages->get(1),
    'current_page' => $page,
]);

You can pass more options to the render method, modifying and overriding custom settings as you go. Here's a slightly more complex example, using placeholders and other custom features to render a single-level main navigation:

echo $modules->get('MarkupMenu')->render([
    'current_page' => $page,
    'templates' => [
        'nav' => '<nav class="{classes} menu--{menu_class_modifier}" aria-label="{aria_label}">%s</nav>',
        'item_current' => '<a class="menu__item menu__item--current" href="{item.url}" tabindex="0" aria-label="Current page: {item.title}">{item.title}</a>',
    ],
    'placeholders' => [
        'menu_class_modifier' => 'top',
        'aria_label' => 'Main navigation',
    ],
    'include' => [
        'root_page' => true,
    ],
    'exclude' => [
        'level_greater_than' => 1,
    ],
]);

Check out the README file for a list of available render options and their default values. There are, among others, options for defining "templates" for specific parts of the menu (list, item, active item, etc.), rules for including or excluding pages, classes to override the module defaults, and placeholders for injecting custom data into menu markup.

It's also worth mentioning that the default options can be overridden on a site level via $config->MarkupMenu (array). This is in addition to the case-by-case override through the options array passed to the render method (as shown above), and can notably cut down the amount of boilerplate code needed every time you render a menu.

Currently MarkupMenu is considered a beta release, so be sure to test carefully before implementing it on a production site. This module also requires ProcessWire 3.0.112+ and PHP 7.1.0+ – so if you're stuck with earlier versions, please use Markup Simple Navigation instead.

If you'd like to give MarkupMenu a try, check out the MarkupMenu modules directory page. This module can be installed with ProcessWire's built-in module installer, by downloading or cloning the module into your modules directory, or via Composer (composer require teppokoivula/markup-menu in your site's root or site directory.)

Site of the week: Kamwell

Our latest site of the week belongs to Kamwell – an employee wellbeing company that provides health and wellbeing solutions for small enterprises to global businesses in a variety of industry sectors. According to their sites directory entry, the new website design needed to allow visitors to immediately understand the essence of their business whilst showcasing their industry knowledge and expertise – and in our opinion this goal was definitely reached!

The Kamwell website is another production from the renowned Internet Dreams Studio. This responsive site has a number of interesting little details baked in, and the design is fresh and airy – with plenty of whitespace and a pleasant, blueish color scheme – and just overall really gorgeous. Content on the site is split into a number of nicely structured content blocks (or "modules"), and the built-in blog feature includes a nice search feature and the ability to list posts based on tags.

Behind the scenes this site makes use of the Bootstrap front-end framework, yet there's no sign of that all too familiar "just another Bootstrap site", for which Bootstrap has become somewhat notorious for. There's a neatly styled embedded Google map on the site, and the share widget is powered by AddThis. Since the site doesn't give away any clues regarding possible third party modules, in this regard your guess is as good as ours.

Big thanks to the folks at Internet Dreams Studio for sharing yet another great project with us, and our congratulations to Kamwell for their new website – looking real sharp!

Stay tuned for our next issue

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

Post a comment