BoltWire is a FREE content management system written in PHP.

Its innovative architecture combined with best-in-class forms processing makes it ideal for creating complex, interactive, web applications fast...




Handbook > Commands > Stamp

The stamp command saves a copy of the current page in the stamps directory, and adds a timestamp to the page name. This makes it possible to revert a page to a former version (the stamp) at some later point using the unstamp command. Often a stamp is made when a page is edited or deleted--so the information can be restored.

Stamp looks for a page in the first parameter position tell which page to stamp, or it defaults to the current page. The stamp command can take pageshortcuts. If the page does not exist, no stamp will be created, but the form will not abort.

When a stamp is created all the data values are also preserved. When the stamp is restored, both the data values and the page content are reverted. Here's an example of how it is used:

[box content cols=40 rows=5]<(source {p})>[box]
[submit value='SAVE']
[command stamp {p}]
[command edit {=content}]

This is a simple form put on an action page used to edit an underlying page. Just before the changes are saved, a stamp is made. If you put the stamp after the edit command, it would save a copy of the page after the changes are made, not before--which would not help.

Expiring Stamps

Because an entire duplicate of a page can be saved each time there is a minor edit--each with a different timestamp--the stamps directory can get very large. To help with this, the stamp command checks to see if any stamps need to be expired whenever a new stamp is saved based on several config values (all can be reset in site.config). Basically, stamps expire if they are:

1) Older than the stampsExpire value (default is 90 days), and it does not drop below the stampsMin number of pages (default is 1).
2) If there are more stamps for a given page than the stampsMax value (the default is 7).

It is recommended that one stamp be kept for each page regardless of its age, so you always have at least one recent backup.

Working with Stamps

Several BoltWire features work with stamps. You can tell if one or more stamps exists for a given page using this conditional:

[if stamp docs.handbook.commands.stamp]True^true0^False

You can search for existing stamps using the search function--just set the dir to stamps and group to {p}. It will list all available stamps (links won't work).

[(search group=docs.handbook.commands.stamp dir=stamps fmt={+p})]

Suppose you had a stamp named (a copy of made at the timestamp specified).

You can actually use include or source to retrieve page content from a stamp into a live page by setting dir=stamps. Include brings in content and allows markup, source brings in content and escapes it.

You can also retrieve data variables from a stamp if you know the full page name. To retrieve a value for the data variable author, you would use {*}. The asterisk tells you to retrieve the value from the stamp. Similarly you can retrieve info vars from a stamp by inserting an initial asterisk. You can even including anchors and parts when referring to the info vars in a stamp, just as if it were a regular page.


To restore a stamp, use the unstamp command and specify which stamp you want to restore. It is best to make a stamp of your current page before reverting to an earlier version of the page in case you change your mind. So always stamp before you unstamp.

The undo action is an interesting study in how stamps work as it generates a list of all available stamps for the current page, displays the content of each one so you can compare versions, and then puts a button below each one that will restore it.