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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

DOM Actions and unpublishing a page


Go to End


2 Posts   1430 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.