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

DOM Actions and unpublishing a page

Go to End

2 Posts   1275 Views


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 ?


Community Member, 21 Posts

20 January 2010 at 8:56am

Still cannot figure this issue out.