smd_at_work

n: smd_at_work | v: 0.22 | f: Development / Textpattern plugins

Documentation for the Textpattern plugin smd_at_work by Stef Dawson follows this short message from our sponsor ;-)

Plugin list buttonPlugin download buttonCompressed plugin download button

smd_at_work

Tell visitors your Textpattern website is undergoing maintenance with the flick of a switch.

  1. Install and enable the plugin [Requires Textpattern 4.6.0+].
  2. Visit the Admin > Prefs panel.
  3. Set Maintenance mode enabled on or off as desired and set the optional message to display.

With the switch on, anyone not logged into the admin side will see a 503 error status and your given message. If you set up an error_503 Page template, that will be delivered instead.

When maintenance mode is on, a message is displayed in the lower-left hand corner of all admin-side panels to remind you of the fact, with a link to the preferences panel so you can easily turn it off.

Public tags

There are two public tags available. One to determine the current state of maintenance mode, and the other to set it on/off. These are of limited use in live templates, but can be very helpful on admin-side dashboards to allow shortcuts for setting the maintenance state of the site.

<txp:smd_if_at_work>

Conditional tag, with no attributes, that executes the contained content if the site is in maintenance mode. Supports <txp:else />.

<txp:smd_at_work_status>

Set the site maintenance state. Attribute:

status

Values:

  • omitted: toggle status
  • 0: set maintenance mode off
  • 1: set maintenance mode on

Note that the plugin only checks to see if the tag is used by any logged-in user. If you wish to exact finer-grained control, you must do so in your Page template.

Example 1: toggle the site state on click of a link

<txp:adi_gps name="maintenance" quiet="1" />

<txp:if_variable name="maintenance" value="">
<txp:else />
   <txp:smd_at_work_status />
</txp:if_variable>

<txp:smd_if_at_work>
   Maintenance Mode is on. <a href="?event=dashboard&maintenance=1">Make site live</a>.
<txp:else />
   Website is live. <a href="?event=dashboard&maintenance=1">Put it in Maintenance Mode</a>.
</txp:smd_if_at_work>

Author/credits

Cobbled together by Stef Dawson, this plugin is a complete rip of the excellent rvm_maintenance plugin, but with the ability to control things via a preference instead of using the plugin’s enabled/disabled state. This makes it easier to manage your site’s status in a disk-based plugin cache environment where plugins are “always on”. Thanks to Ruud van Melick for the original plugin.

Source code

If you’d rather wander aimlessly through thousands of lines of PHP source code, you’ll need to step into the view source page.

Legacy software

If, for some inexplicable reason, you need an old version of a plugin, it can probably be found on the plugin archive page.

Experimental software

If you’re feeling brave, or fancy skateboarding into volcanos, you can test out some of my beta code. It can be found on the plugin beta page.