Summary: Talk page for DeletePage.
Maintainer: Petko (Original authors: 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.

Add a redirect page option to page deletion

It would be nice to add a redirect option to the delete action. This might be a total no-no, but I have action=delete links on many of my pages, as many pages are "items" in a "list" and there are times I need to delete the current page (item) from a "list". The "list" has a "head" page that it would be nice to redirect to once the current page is deleted. Any chance that could be added, similar to fox forms like, "Page?action=delete&redirect=PageName" ? In my scenario, it does not make scene for the system to return to a page that was just deleted.
DannyB May 6, 2022, at 3:22 PM

Released version 20220507 with added variable $DeleteRedirectPage -- see Installation section. This is a page name format defined in local.php, but you can do it dynamically, for example:

if($action == 'delete' && @$_REQUEST['redirect']) {
  $DeleteRedirectPage = MakePageName($pagename, $_REQUEST['redirect']);


Thanks for adding that feature! It makes my list management MUCH more user friendly. The dynamic specification code above is what made this usable. I'm not sure why you would want a static page to go to when a page is deleted.
DannyB June 1, 2022, at 5:27 PM


I noticed DeleteAction is named "DeletePage" and uses "deletepage.php" .. which seems to irritate the analyze feature, which detects "DeleteAction" and "DeletePage" within the list of recipes. Is this know and on purpose ?
Changing the code line:
$RecipeInfo['DeletePage']['Version'] = '2005-08-10';
$RecipeInfo['DeleteAction']['Version'] = '2005-08-10';
would fix that issue.
Also the recipe file could be renamed from "deletepage.php" to "deleteaction.php". It would state the actual name.
Loria March 16, 2021, at 12:15

Thank you Loria for your report. Indeed, we could rename and edit the file, but it is easier to just rename the page on the Cookbook. Please report if this hasn't fixed the problem. --Petko March 16, 2021, at 11:28 AM

Indeed renaming the page has not fixed the problem. Changing the $RecipeInfo line in the script does, though… but, oddly enough, it makes RecipeCheck show two lines, one for DeletePage (with a matching version local vs., and one with an unknown version. Screenshot. —Said Achmiz November 15, 2021, at 10:52 PM

Thank you Said, this was fixed, finally. I found that some recipes are mapped manually in Cookbook:RecipeMap and this caused the recipe list on to have this obsolete reference. --Petko November 16, 2021, at 07:14 PM

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 DeletePage recipe (users?).