Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Removing the ‘Delete from the draft site’ button for published pages.

Go to End

9 Posts   3757 Views


Community Member, 38 Posts

26 November 2010 at 8:03pm

I was also looking for the same sort of control, notably to force the use of requests in CMSworkflow so admins didn't just save and publish. Then it occurred to me that it would also be nice to remove delete from draft vs unpublish etc at strategic times. You've probably solved it somewhere else by now however:


	extends SiteTree to remove some buttons from CMS at relevant times to force

	* Save and Publish - always removed to force use of publication request when
		the CMSWorkflow module is installed. Comment out if not using module.
		Wonder if could check to see if CMSWorkflow there and automate.
	* Delete From Draft Site - removed when page is published to force unpublish 
		before allowing delete from the site.
	* Unpublish - removed when page has unpublished changes to force cancellation
		of changes first. However as it seems to stay on 'changed in stage' 
		even if you do the cancel draft changes and it copies in from the published version 
		it still seems to return true for changed until published... so that has been 
		commented out.

	add to site _config.php with Object::add_extension('SiteTree','RemoveCMSButtonsDecorator');

class RemoveCMSButtonsDecorator extends DataObjectDecorator {

	public function updateCMSActions(&$actions) {
		$owner = $this->owner;
		$changed = $owner->getIsModifiedOnStage();
		$published = $owner->isPublished();

		$savepublishbutton = strtolower(_t('BUTTONSAVEPUBLISH','Save and Publish'));
		$unpublishbutton = strtolower(_t('BUTTONUNPUBLISH','Unpublish'));
		$deletedraftbutton = strtolower(_t('CMSMain.DELETE','Delete from the draft site'));

		foreach($actions as $anaction) {
			$title = strtolower($anaction->Title());
//			if ($changed && ($title == $unpublishbutton)) $actions->remove($anaction);
			if ($published && ($title == $deletedraftbutton)) $actions->remove($anaction);
//			if ($title == $savepublishbutton) $actions->remove($anaction);


Go to Top