Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » DOM Actions and unpublishing a page

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

Page: 1
Go to End
Author Topic: 1015 Views
  • paul.mcilwaine
    Avatar
    Community Member
    21 Posts

    DOM Actions and unpublishing a page Link to this post

    I am using the DataObjectManager with Actions which looks after a particular page type. The action ive placed on each item is to either publish the page if its not published or unpublish it if its published. The code thats gets invoked when trying to do this from the action is seen below

       public function handleStatus( $request )
       {
          $SQL_id = Convert::raw2sql($request->param( "ID" ) );

          $page = DataObject::get_by_id("SiteTree", $SQL_id);
          if($page && !$page->canPublish()) return Security::permissionFailure($this);

          if ( "Published" == $page->Status ) $page->doUnpublish();
          else $page->doPublish();
       }

    Currently only the SiteTree tables status is updated from what Ive seen and when going to this page the "Cancel draft changes" button appears, as well as the page still being Published (on the live stage). What do I need to add to make sure this code does what its meant to do ?

  • paul.mcilwaine
    Avatar
    Community Member
    21 Posts

    Re: DOM Actions and unpublishing a page Link to this post

    Still cannot figure this issue out.

    1015 Views
Page: 1
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.