Advertisement
  1. Web Design
  2. Processwire
Webdesign

7 Tricks and Tips to Help You Become a ProcessWire Master

by
Difficulty:IntermediateLength:ShortLanguages:

From admin tricks to modules, API and templating, here is a list of tips and tricks to help you become a ProcessWire master!

1. Bulk Delete Images in Admin

As you create your site content, you may have uploaded from a few, to hundreds of images to a particular page that you may no longer want. Should you need to get rid of them, instead of deleting each image individually, you can bulk delete images from any image field by double-clicking the bin icon. This will delete all images within the field after save.

Bulk delete images within Prcoesswire admin
Bulk delete images within the PrcoessWire admin

2. Regain Entry to Backend

Every so often you may find yourself locked out of the ProcessWire admin; perhaps you’ve lost your password, are midway through a site migration, or neglected to install the forgotten password module (disabled by default for security reasons). Appending this PHP script to “site/templates/admin.php” and navigating to the login page will set a new password for the admin user.

Remember to delete the script and save “admin.php” as soon as you are in.

3. Migrate From WordPress to ProcessWire

ProcessWire is extremely flexible; it can handle many different data migrations and imports from other systems or feeds (xml, csv, and more). One of the most common use cases is migrating WordPress site data to ProcessWire, which can be done using a couple of very useful modules.

  1. Firstly, export all the data from your WordPress install by going to (WordPress) Tools > Export.
  2. Install the ProcessWire module ProcessMigrate and the ”submodule“ MigrateWordpress.
  3. Go to (ProcessWire) Setup > Migrator and select Import.
  4. Choose your previously exported WordPress XML file and let the modules do the rest!
Migrating WordPress to ProcessWire

4. Upgrade ProcessWire

Upgrading is a chore for most CMS’s. In ProcessWire however, It’s generally a painless case of replacing a few files and folders and checking that modules are still working. The rationale for upgrading your ProcessWire install is generally for speed and functionality improvements, as opposed to security issues (I’m yet to hear of any ProcessWire hacks).

The upgrade procedure is a question of replacing the “wire/” folder, “index.php” and “.htaccess” files of your site to the version you’re upgrading to. However, always make a backup before making changes, and be sure to check the upgrade notes for your specific version on the GitHub repo.

5. Graceful “Stop Markup Output” in Templates

Within your site templates you may want to halt output after some page logic; for example, halting further output after detecting an AJAX request and serving other data instead. Normally in PHP you would use the die() or exit() methods, however this stops PHP execution and prevents ProcessWire from carrying out its post template rendering processes (to which you can add functions if needed, see below). Instead, you should use return $this->halt(); within your templates (use outside of any function or class scope) to halt template rendering but continue towards ProcessWire’s normal shutdown.

6. Add Global Functionality

You can add functionality to ProcessWire in several ways:

  • Add global functionality by including your functions file in the “site/config.php. This will then be callable anywhere within ProcessWire including your templates: include_once(dirname(__FILE__) . "/myPath/myFunctions.php");Thanks to Horst for this tip!
  • By creating your own modules you can add functionality anywhere within ProcessWire. Your modules will be portable to other ProcessWire installations too, and hopefully open sourced for the ProcessWire community to enjoy!
  • Lastly, you can add hooks to ProcessWire functions within your template by utilizing the “init.php”, “ready.php” and “finished.php” files that are called, in that order, when your templates are rendered before “finished.php”. Learn more about this on the ProcessWire blog.

7. Sanitize Everything!

I would hope that anything that is input to your site or app goes through a certain amount of sanitization; that when your site stores data it isn’t open to security risks like SQL or Script injections.

ProcessWire’s API comes with some common methods to sanitize text, emails, url, numbers and so on. For example, the $sanitizer->date() method will sanitize a date or date/time string, check it’s valid, and return it:

Use them! You’ll find the full list in the ProcessWire documentation.

Lastly, Ask the Community

As a final tip, I can’t recommend the ProcessWire community enough. ProcessWire enjoys a vibrant developer community around the world comprising some of the most helpful people you can imagine; ask anything you like on the ProcessWire forum

Also don't forget to check out ProcessWire Weekly, the place to find out about hot topics on the forums, a showcase of websites made with ProcessWire, new modules, and system updates from ProcessWire’s core team. And, of course, keep an eye on Envato Tuts+ for more ProcessWire tutorials in the future!

Advertisement
Advertisement
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.