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.

Customising the CMS /

DOM Actions and unpublishing a page


Reply


2 Posts   1112 Views

Avatar
paul.mcilwaine

Community Member, 21 Posts

14 January 2010 at 6:37pm

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 ?

Avatar
paul.mcilwaine

Community Member, 21 Posts

20 January 2010 at 8:56am

Still cannot figure this issue out.