Summary: Talk page for DeleteAction.
Maintainer: Pm, Klonk
Users: (View? / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.


I just wanted to point something out that may seem obvious to experienced users:
1) After the deletepage.php script is added, the line include_once("cookbook/deletepage.php"); must be added to the local configuration file. (assuming the file was placed in the cookbook/ directory). Menachem January 20, 2005, at 02:03 PM

I've added the instructions for this into the script directly -- thanks. --Pm

I think it would be great if the delete action could display a confirmation page. That way I would feel more comfortable adding a Delete action link. Right now if somebody accidentally clicks it when they try to click edit or history, they'll wipe the page (I know we can retrieve but it's a bit of a pain). --NoelLlopis

Hmm, writing confirmation pages is a bit of a pain too. It's probably a bad idea to have ?action=delete directly in the template or file anyway, as a search engine robot will activate all of your delete links. :-) For the time being I suggest making sure that ?action=delete is always password protected:

$DefaultPasswords['delete'] = '*';

This will prevent robots from activating delete links. I'll also see about providing a confirmation capability of some sort. --Pm
Could this be done with JavaScript of some sort? (among others) has some examples --Anonymous
Something like <a href=somefile.php?action=delete&delete=yes onClick="return confirm('Are you sure you want to delete this?')">
if (isset($_GET['delete']) && ($_GET['delete']=="yes")) {
delete... --Kab July 15, 2005, at 09:35 AM
Well yes, I make a javascript and it works! All you need to do is to put the following lines to your .tmpl file in your skin, and you will get a "delete page" link with confirm function.
<script language="JavaScript">
function confirmSubmit()
{var agree=confirm("Are you sure you wish to continue?");
if (agree)
return true;
return false;
<a onClick="return confirmSubmit()" href='$PageUrl?action=delete' accesskey='ak_delete'>Delete Page</a>
Starting with version 2.0.beta50, you can password-protect the action with
$HandleAuth['delete'] = 'edit';
$HandleAuth['delete'] = 'admin';
to require the edit or admin password respectively. Klonk
I modified this delete link on the .tmpl file, so it would not appear if user not logged in.
<a onClick="return confirmSubmit()" href='$PageUrl?action=delete' accesskey='ak_delete'>$DeleteText</a>
And put the following lines on config.php or farmconfig.php :
if ($LoginName == 'Logout')
{$DeleteText = 'Delete This Page';} else {$DeleteText = '';}
$HandleAuth['delete'] = 'edit';
to make this work. --deelar
  • Wouldn't an alternative way to do this whole thing be to add a link along the lines of [[{$Name}?action=edit?text=delete | Delete]] to Site.PageActions? -i.e prepopulate the edit box with the word delete through the url - Not sure of the exact syntax. This would have the benefit of teaching the user the standard delete mechanism and allowing them to confirm. Francis March 02, 2007, at 09:32 AM

Why isn't the delete password shown next to the change delete password box on the Attributes page? All the other attributes show what password they're using (**** for a normal password, and id: or @group for AuthUser passwords) next to the box where you type to change it, but delete doesn't. --Daniel

Philippe? - 2010-11-23: This is because something is missing from the recipe. It took me a while to track down, and I hope it's correct, but you must add SDV($FmtPV['$PasswdDelete'], 'PasswdVar($pn, "delete")'); in addition to the include_once("$FarmD/cookbook/deletepage.php");

SteP 2010-11-26: Philippe is right, SDV needs adding either in your configuration file or with the other SDV statements in the recipe PHP file. In addition, you may want to add markup to SiteAdmin.AuthList to list delete attribute values.

DenningServices(.com) 20151214: Here is your complete edit scenario for implementation of this cool script.
The files and pages of server file local/config.php, and wiki pages SiteAdmin.AuthList and Site.PageActions can be edited to add the following:

local/config.php Edits
SDV($FmtPV['$PasswdDelete'], 'PasswdVar($pn, "delete")'); // Allow function to be password protected.

SiteAdmin.AuthList Edits
Under the conditional: (:if exists {=$Group}.GroupAttributes:)
Add the following line: ||delete ||{{=$Group}.GroupAttributes$PasswdDelete} ||
I put mine right after the one for Edit.

Under the conditional: (:if ! equal {=$Name} GroupAttributes :)
Add the following line: ||delete ||{=$PasswdDelete} ||
Once again, mine is after Edit.

Site.PageActions Edits
For Tabs you can also put "DELETE" instead of "DELETE THIS PAGE"
This allows Admin access only by default. If any other editors also need to see it who are not an Admin, then take the conditional away from the accesskey listing and manage each group or page attribute accordingly. Remember: with no conditional, every page will be at risk.
(:if auth admin:)
[-'''No Confirm / No Undo'''-]
* %item rel=nofollow class=delete accesskey='$[ak_delete]'% [[{*$FullName}?action=delete | %color=red%[-'''''$[DELETE THIS PAGE]'''''-]%%]]

Now, the only thing left to do is copy the module to restorepage.php and use the renaming convention to be called by a pop-up that allows pages to be listed and restored. I may work on that one later.
I hope this helps. Shalom.

Talk page for the DeleteAction recipe (users?).