Editing pages
Version history
Every save of the blocks of a page creates a version. You can look at a previous version in the Editor, put it back online and name the important versions.
What is recorded
- A version is created by every save that changes the blocks of the page: content, order, a block added or removed. A save that does not change the blocks creates no version.
- The history is kept per language: each language of the page has its own versions.
- Each version keeps its date, its author and its number of blocks.
- Versions are created whatever the way the page is saved: from the Editor, from the classic page form or from code.
- For a page created before 2.3, the first save also keeps the previous state of the blocks: that first change can be undone.
The history contains the blocks only. The title, URL, layout, SEO fields and publishing are not part of it: restoring a version does not change them.
Open the history
- Open the page in the Editor.
- Click History in the document toolbar. The button is available once the page is saved.
- The Block history dialog lists the versions of the displayed language, newest first. The version online is labelled Current version.
The search field filters the versions on their title and description.
Go back to a previous version
- In the history, click Preview on the version you want. If the page has unsaved changes, a confirmation warns you that they will be lost.
- The blocks of that version are shown in the Editor and in the preview. A banner tells which version is displayed, and the tab is flagged as changed.
- Click Save: that version is put back online.
To leave the preview without changing anything, click Back to the current version in the banner.
Restoring a version deletes nothing: the save creates a new version, and the newer versions stay in the history. You can always go back.
Before saving, you can also edit the blocks of the previewed version: they are saved like any other change.
Name a version
Give a name to the important versions, for example before a redesign or for a campaign:
- In the history, click Name / Edit on the version.
- Enter a Title and, if needed, a Description.
- Click Save.
How many versions are kept?
- The last 50 versions are kept per page and language. Older ones are deleted automatically.
- Named versions (with a title) are never deleted automatically and do not count towards that limit.
- Deleting a page also deletes its history.
For developers
The history is built on the LucasPalomba\PageTree\Traits\Versionable trait, which your own models can use:
class Article extends Model
{
use \LucasPalomba\PageTree\Traits\Versionable;
// Attributes with a history
public $versionable = ['content'];
// Unnamed versions kept per record and language
public $versionableLimit = 50;
}
- Versions are stored in the
lucaspalomba_pagetree_versionstable and available through thepagetree_versionsrelation. - With RainLab.Translate, each saved language has its own versions.
- Until
php artisan october:migratehas created the table, models are saved as usual, without history.