ProcessWire 3.0.33 and 2.8.33

I'll keep today's post short, as this week's updates have been mostly housekeeping related. Last week we had a lot of positive feedback from you about moving to the new ProcessWire account on GitHub, so thank you for your responses!

We've gone ahead and converted that account to be a GitHub organization, and in the weeks ahead we'll be figuring out how best to utilize the new capabilities. Though so far, it looks like GitHub's organization features are very limited in terms of access control at present, so may not give us as much to work with as we'd like. But it's still a lot better than without it, so I can't complain.

To get things started, I've pushed ProcessWire 3.0.33 RC1 to this new organization account in the new ProcessWire repository. This is our way of testing things out. You'll see the same version posted on the devns branch of our old repository, so it doesn't matter where you download it from. But once 3.x is our new official version, then this new repository is where you'll want to get it from.

In terms of actual release date for 3.x, we're going to target September 23, 2016. I'd aim for a week or two earlier, except that I've got to travel a bit between now and then, and I'd like to be fully present upon release, so this date is what works the best. There likely won't be any major code changes until official release, just bug fixes for anything that turns up.

Speaking of code changes, nearly every file in the core code base changed this week, but it was primarily aimed at updating code comments in file headers for version and dates, in preparation for the 3.x release. Beyond that, several updates were made to phpdoc documentation in files, and several minor bugs were fixed per GitHub issue reports. For more details on that see the commit log.

Recipe: hooks and partials

Last week the ProcessWire Weekly started a new recipe of the week, and since this week's post is kind of short I thought I'd also throw one out there I've been experimenting with this week.

Every now and then, I need to include some kind of partial in the middle of a CKEditor field. Something like a subscribe form, photo gallery, PayPal donate button, things of that sort. Basically anything that takes some markup that wouldn't usually work in a rich text field. For example, lets say I've got these files as my partials:

  • /site/templates/includes/subscribe-form.php
  • /site/templates/includes/donate-button.php
  • /site/templates/includes/photo-gallery.php

…and I want to be able to include any of them in my body copy (CKEditor/Textarea) field just by typing "include" and the name of it on it's own line, for example:


Here's a hook you can put in your /site/ready.php file that will let you accomplish this:

$wire->addHookAfter('FieldtypeTextarea::formatValue', function($e) {
  if(strpos($e->return, "<p>include-") !== false) {
    $regex = '/<p>include-([-_a-zA-Z0-9]+)\s*<\/p>/';
    if(preg_match($regex, $e->return, $matches)) {
      $file = $e->wire('config')->paths->templates;
      $file .= "includes/$matches[1].php";
      if(is_file($file)) {
        $out = $e->wire('files')->render($file);
      } else {
        $out = '<p>file does not exist</p>';
      $e->return = str_replace($matches[0], $out, $e->return);

You might notice this is kind of like a home brewed Hanna Code. The benefit over Hanna Code in this case is that the file is included in your site's /site/templates/ files, and thus managed along with the rest of the code in your site. Of course there are also benefits to using Hanna Code, but this is just one more tool in your toolbox that is nice when you want all of your code together in one spot.

As another (perhaps simpler) example, lets say that you want to be able to output a Font Awesome icon anywhere that you type "", i.e.

Have questions?

We'll assume you have already loaded Font Awesome's CSS file (if not, here's how). And here's how you might automatically convert that "" to a Font Awesome icon on the front-end (again, in your /site/ready.php file):

$wire->addHookAfter('FieldtypeTextarea::formatValue', function($e) {
  if(strpos($e->return, 'icon-') !== false) {
    if(preg_match('/icon-([-a-z0-9]+)/', $e->return, $matches)) {
      $icon = "<i class='fa fa-$matches[1]'></i>";
      $e->return = str_replace($matches[0], $icon, $e->return);

Hope that you all have a great weekend, and be sure to check out the ProcessWire Weekly this weekend!


  • Szabesz


    • 3 years ago
    • 02
    Thank you Ryan! I do like this "home brewed Hanna Code" a lot. It could even be extended with parameters like this (for example):
    where -- separates the file name from the key/value pair of the parameter.
    It just needs to be implemented first :)
  • ryan


    • 3 years ago
    • 00
    You can use $e->wire('config') or wire('config'). Using the wire() method call off of any ProcessWire object (like the HookEvent $e) is preferable in PW3 since it supports multi-instance. Pulling it from $e ensures there's no ambiguity about what instance it is. But if you aren't using multiple instances at once, then it makes no difference. It's more just like a best practice. That $value was a typo, it should be $e->return.
  • Zahari M

    Zahari M

    • 3 years ago
    • 01
    This particular include feature is simply awesome Ryan!!!

    Just curious.. is this site/ready.php a special file? I don't think I have come across it before...

  • ukyo


    • 3 years ago
    • 11

    You can check this post for ready.php

    • Manlio


      • 3 years ago
      • 00
      Ok I solved! The text was in side a tag and prevent it from working. Now everything is perfect! Thank you
    • mp


      • 3 years ago
      • 01
      Cool idea. But where is $value coming from? And what is the diff between $e->wire('config')->paths->templates and wire('config')->paths->templates?
      • Manlio


        • 3 years ago
        • 00
        Hi and thank you for the excellent work! I'm trying to substitute some hanna code script with this fantastic recipe but I'm not able to make it work. I have a multilanguage field so I changed the code from "FieldtypeTextarea::formatValue" to "FieldtypeTextareaLanguage::formatValue".
        I have updated to the latest processwire version and created ready.php file in site directory. Debug is true but I don't see any errors in admin interface. Any idea? Thank you.

        Twitter updates

        • Weekly update for Jan 10, 2020—front-end file uploads in LoginRegisterPro with InputfieldFrontendFile module: More
          10 January 2020
        • If you haven't seen it yet, be sure to check out this great infographic by @teppokoivula in ProcessWire Weekly #294— How ProcessWire professionals work—the results of our recent weekly polls summarised:…
          3 January 2020
        • Today we have a new master version released, 3.0.148! There are 25 new versions worth of upgrades, fixes and optimizations in this new master version, relative to the previous. In this post we take a closer look at what’s new, how to upgrade, & more— More
          3 January 2020

        Latest news

        • ProcessWire Weekly #298
          In the 298th issue of ProcessWire Weekly we're going to take a quick look at the latest core updates, introduce the PWGeeks project, and highlight some recently released ProcessWire content. Read on!
 / 25 January 2020
        • ProcessWire 3.0.148 new master
          Today we have a new master version released, version 3.0.148! The last master version was 3.0.123, so there are 25 new versions worth of upgrades, fixes and optimizations in this new master version, relative to the previous. In this post we’ll take a closer look at what’s new, how to upgrade, and more.
          Blog / 3 January 2020
        • Subscribe to weekly ProcessWire news

        “Yesterday I sent the client a short documentation for their ProcessWire-powered website. Today all features already used with no questions. #cmsdoneright—Marc Hinse, Web designer/developer