This document contains information for an outdated version (2.3) and may not be maintained any more.
If some of your projects still use this version, consider upgrading as soon as possible.
Versioned
The Versioned class is a DataObject that adds versioning and staging capabilities to the objects.
Trapping the publication event
Sometimes, you'll want to do something whenever a particular kind of page is published. This example sends an email whenever a blog entry has been published.
SilverStripe 2.3
class Page extends SiteTree {
// ...
function publish($fromStage, $toStage, $createNewVersion = false) {
mail("sam@silverstripe.com", "Blog published", "The blog has been published");
return $this->extension_instances['Versioned']->publish($fromStage, $toStage, $createNewVersion);
}
}
SilverStripe 2.4
class Page extends SiteTree {
// ...
function onAfterPublish() {
mail("sam@silverstripe.com", "Blog published", "The blog has been published");
parent::onAfterPublish();
}
}

Comments
Comment policy: Please use comments for tips and corrections about the described functionality.
blog comments powered by DisqusComments are moderated, we reserve the right to remove comments that are inappropriate or are no longer relevant. Use the Silverstripe Forum to ask questions.