Jump to:

5537 Posts in 1737 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Removing the ‘Delete from the draft site’ button for published pages.

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

Page: 1 2
Go to End
Author Topic: 2669 Views
  • pter
    Community Member
    38 Posts

    Re: Removing the ‘Delete from the draft site’ button for published pages. Link to this post

    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);


Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.