5121 Posts in 1527 Topics by 1119 members
| Go to End | Next > | |
| Author | Topic: | 2272 Views |
-
Removing the ‘Delete from the draft site’ button for published pages.

27 January 2009 at 1:02pm
Hi,
I want to remove the ‘Delete from the draft site’ button for published pages. (i.e. I only want this button present if the user has unpublished the page)
This is the code (in cms/code/CMSMain.php) that adds the button, I need to include in the if condition that the record is unpublished.
else {
if($record->canEdit()) {
$actions->push($deleteAction = new FormAction('delete',_t('CMSMain.DELETE','Delete from the draft site')));
$deleteAction->addExtraClass('delete');
}Does anyone know how I would code $record-> is unpublished?
Many Thanks
Billy
-
Re: Removing the ‘Delete from the draft site’ button for published pages.

27 January 2009 at 2:04pm
Try $record->Published()
-
Re: Removing the ‘Delete from the draft site’ button for published pages.

27 January 2009 at 2:10pm
Also, you don't need to mod the core code. Just add the method getAllCMSActions() to your model class.
-
Re: Removing the ‘Delete from the draft site’ button for published pages.

29 January 2009 at 1:33pm
Thanks UncleCheese
got it sorted
-
Re: Removing the ‘Delete from the draft site’ button for published pages.

29 January 2009 at 2:24pm
hi wdi2
any chance you could post your final code for people who might be interested
cheers
-
Re: Removing the ‘Delete from the draft site’ button for published pages.

1 February 2009 at 11:20pm Last edited: 1 February 2009 11:21pm
No probs, I should have done that
Added the following in Sapphier/core/model/SiteTree.php
----------------------------------------------------------------------------------------------
function getCMSActions() {
$actions = array();
if(!$this->isPublished()) {
$deletedraft = FormAction::create('delete',_t('CMSMain.DELETE','Delete from the draft site'), 'delete');
$deletedraft->addExtraClass('delete');
$actions[] = $deletedraft;
}
-------------------------------------------------------------------------------------------------removed the following in cms/code/CMSMain.php
-------------------------------------------------------------------------------------------------
// getAllCMSActions can be used to completely redefine the action list
if($record->hasMethod('getAllCMSActions')) {
$actions = $record->getAllCMSActions();
} else {
$actions = new FieldSet();if($record->DeletedFromStage) {
if($record->can('CMSEdit')) {
$actions->push(new FormAction('revert',_t('CMSMain.RESTORE','Restore')));
$actions->push(new FormAction('deletefromlive',_t('CMSMain.DELETEFP','Delete from the published site')));
}
} else {
/*if($record->canEdit()) {
$actions->push($deleteAction = new FormAction('delete',_t('CMSMain.DELETE','Delete from the draft site')));
$deleteAction->addExtraClass('delete');
}*/
------------------------------------------------------------------------------------------------------------------Updated Button name in cms/lang/en_US.php
Not sure if this is the best way to get there, but it works.
-
Re: Removing the ‘Delete from the draft site’ button for published pages.

6 November 2009 at 5:27am
Did anyone figure out how to do this without moding the core? If so, could you please post your code that goes in the page model class here.
-
Re: Removing the ‘Delete from the draft site’ button for published pages.

4 February 2010 at 6:16am
Thank you. After the third time my client deleted whole sections of their website and I had to muck around in the database to hook the pages back up, I decided I needed to remove the 'Delete from draft site' button for published pages.
While my SiteTree.php was slightly different than what was posted, I was able to get it to work.
How can there be such a catastrophic delete function without even a "Are you sure? confirmation dialog?
| 2272 Views | ||
| Go to Top | Next > |



