ProcessWire Weekly #134

The 134th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!

Welcome to the 134th issue of ProcessWire Weekly! For this week's issue we've got a new module from Adrian Jones, a handy recipe of the week for runtime caching function and method return values, and of course our regular core updates from Ryan – and a brand new site of the week.

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

In the latest post at the blog Ryan introduces the latest development version of ProcessWire, 3.0.43, which brings in fixes and a couple of all new features too. Here are the highlights of what was changed and/or updated this week:

  • Accessibility improvements for our built-in site profiles and the MarkupPagerNav module, plus MarkupPagerNav optimizations and documentation updates
  • Major improvements to the touch device support of the admin tools and also some improvements to the Field editor
  • New /*NoCompile*/ and FileCompiler=? options for the FileCompiler make it possible to tell the system to not compile specific include files, such as those belonging to an external library or a framework
  • New features for the $page->url() method allow you to easily modify the return value of this method by providing an optional $options array – or one of the supported shortcut params

In addition to aforementioned improvements and newly added features, there were also various fixes to CommentsManager, InputfieldRepeater, InputfieldInteger, multi-instance support, and a rather specific issue related to bootstrapping ProcessWire within a WordPress site.

For more details about this week's core updates and particularly the new features for FileCompiler and $page->url() – plus a new version of our last week's recipe of the week refactored to use the new URL features – please check out Ryan's post at the blog. Thanks!

New module: Restrict Multi-Language Branch by Adrian Jones

Restrict Multi-Language Branch is a new module by Adrian Jones. In a nutshell it adds even more flexibility to ProcessWire's already quite flexible multi-language features: in addition to the ability of enabling multi-language fields on template level, this module allows you to enable or disable the multi-language features on page or branch level.

Via module settings you can review all currently active multi-language restrictions and set the multi-language features enabled or disabled by default. There's also page level setting that let's you enable or disable multi-language features either for a single page only, or for that page and all it's children, grandchildren, etc. recursively.

One feature Adrian has mentioned on the forum but which may still require some core adjustments would be enabling or disabling specific languages on page or branch level. We'll see how that goes, but to be honest this module is already very useful for certain cases, whether or not this feature gets added.

You can grab the module from GitHub, and for any questions and support requests you should head down to the dedicated support forum thread. Once again big thanks to Adrian for sharing your work with us!

Recipe of the week: runtime caching for your own functions and methods

While ProcessWire has a collection of flexible, built-in tools for caching, sometimes those tools don't match your needs perfectly, and thus it's always good to have a few extra tools in your belt for such situations. Our latest recipe of the week was borrowed from the ProcessWire Recipes directory and very slightly edited for this week's issue.

The problem

In your modules (or somewhere else) you have expensive calculations to make, or you simply want to cache a result of a method / function when it's parameters / data do not change on runtime and it’s still accessed multiple times.

The solution

Here's an example function that makes use of a static cache variable, which in turn enables us to store return values effectively for future reference:

function expensiveStuff($name, $someOtherParam, $forceNew = false) {
    // This static $cache is scoped to the function and will be created only
    // once despite called multiple times
    static $cache = null;
    if (is_null($cache)) $cache = array();

    // Generate a unique ID here, this is just an example
    $id = "{$name}-{$someOtherParam}";

    // Return the cached result if it exists _and_ it should not be recalculated
    if (!$forceNew && array_key_exists($id, $cache)) return $cache[$id];

    $result = '... expensive code here ...';

    // Save the result in the cache and return it
    return $cache[$id] = $result;

Note: this method makes use of a runtime cache, meaning that nothing is saved to disk or the database. For many cases you should be using the built-in $cache API variable or, even better, the built-in Template caching. Still, this technique is useful for cases where the built-in methods don't fit – or perhaps in addition to them.

This week's recipe was borrowed from the ever growing ProcessWire Recipes directory. If you've got a recipe of your own that you'd like to share with others, feel free to submit it at ProcessWire Recipes.

Site of the week: Fabrica Capital

Our latest site of the week belongs to the London, UK based commercial real estate investment company Fabrica Capital, who – in their own words – strive for a positive impact on the investor, community, occupier and the environment. Their new site is a one-page site with a pretty unique design, where the bulk of the content is formed by square blocks spiced up with simple shapes and placed on top of a full-screen video.

While there are various factors that make a site a candidate for a site of the week title, in this case the design – handiwork of another London based company, Crook Design – is what really makes this site stand out from the crowd. Great design is always an asset, and this site once again proves that great looks and usability can go hand in hand.

The development work for this site was done by Ben Byford, and there's not much to complain there either: the site feels fast, scales nicely to all sorts of screens, and so on. Behind the scenes AIOM+ is used to minify and combine resources, but that's just about all we can say about the tech side of things.

Big thanks to Ben Byford for sharing this site with us, and our congratulations to the client and the whole team behind this project – this is a great site in more than one way, so definitely a job well done!

Stay tuned for our next issue

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