Documentation for the Textpattern plugin smd_at_work by Stef Dawson follows this short message from our sponsor ;-)
If you like my code and it makes your site better, feel free to show your appreciation with something from my UK Amazon wish list (or US) or donate to the Stef Dawson community coding pot, either via paypal.me/stefdawson by following the Donate button below to PayPal. Thanks!
Tell visitors your Textpattern website is undergoing maintenance with the flick of a switch.
- Install and enable the plugin [Requires Textpattern 4.6.0+].
- Visit the Admin > Prefs panel.
- 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.
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.
Conditional tag, with no attributes, that executes the contained content if the site is in maintenance mode. Supports
Set the site maintenance state. Attribute:
- 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>
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.
If you’d rather wander aimlessly through thousands of lines of PHP source code, you’ll need to step into the view source page.
If, for some inexplicable reason, you need last century's version of a plugin, it can probably be found on the plugin archive page.
If you’re feeling brave, or fancy going bareback, you can test out some of my beta code. It can be found on the plugin beta page.