In Silverstripe I’m using the method OnBeforeWrite to trigger a function when a page is updated or saved.
Documentation: http://api.silverstripe.org/2.4/cms/SiteTree.html#methodonBeforeWrite
Is there a way I can differentiate between writing to the Stage website (“Save” button) and the Live website (“Save & Publish” button)?
When you save a page SS will always do a
write(). When you ‘save and publish’doPublish()is also called. http://api.silverstripe.org/2.4/cms/SiteTree.html#methoddoPublishThe
SiteTreeDecoratoralso has anonBeforePublishmethod. You may want to look into using that. http://api.silverstripe.org/2.4/sapphire/model/SiteTreeDecorator.html#methodonBeforePublish