Summary: An easy way to add information to a page and delete it again.
Version: 2.0.3
Prerequisites: Forms
Status: stable
Maintainer: Nils Knappmeier
Categories: Blog, Editing, Forms, Obsolete


Unless you are running a very old version of PmWiki and php, you should instead use AddDeleteLine3.

Questions answered by this recipe

  • How can I add data to a page without having to click on edit?
  • How can I create lists, where users can enter information using a web form?

A very similar recipe with slightly different features is the Fox recipe. If you think that this recipe is nice, but not exactly what you are looking for, then maybe you find it in Fox.


An easy way to add information to a page and delete it again.

The AddDeleteLine recipe provides a way to insert form-data at a pre-defined location in a wiki-page. The input form is created by the commands in the Forms recipe. The markup in this recipe allows the user to specify the formatting of the input data in a template-string or template-page, and to define where the form-data should be inserted in the page.

Installing instructions

In order to use this recipe, download the file adddeleteline2.phpΔ into your cookbook/-directory and add include_once('cookbook/adddeleteline2.php'); to your local/config.php

Upgrading from AddDeleteLine 1.x

For instructions how to upgrade from AddDeleteLine v1 to AddDeleteLine2, please refer to the instructions on the bottom of this page


For examples and a playground, go to the Adl2Examples on (PW: "tryadl2")


The markup can be seperated in three parts:

In order to prevent naming ambiguities, the directives defined in this receipe begin with adl (add delete line).

Input form markup

The typical declaration of an input is

(:adl form name [target=[Group.]Page]:)

// Input field declaration

(:adl template "string":)
(:adl end:)

  • [Group.]Page is an optional parameter that defines the wiki-page to which the input should be inserted. If no target is specified, the data is inserted into the current page.
  • name is used to identify the correct location within the target page, at which the input data should be inserted. The implicit names #top and #bottom can be used to prepend data at the beginning or to append it to the end of the page.
  • The input field declaration is done using the Standard Input Controls of the Forms recipe.
  • The string is the text that is actually inserted into the page. It can contain markup that is replaced by the value of the input field or the current date.

If the template string consists of more than one line, it may be useful to specify the template in a seperate wiki-page. In this case, the markup

    (:adl templatepage [Group.]Page:)

should be used.

Anchor markup

The following directives must be written on the target page at the position, where the form data should be inserted.

(:adl prepend name:)
Specifies that data from the form named name is inserted here. Newer entries appear above older entries.
(:adl append name:)
Specifies that data from the form named name is inserted here. Newer entries appear below older entries.
Note: If the implicit names #top and #bottom are used in the form, no (:adl prepend name:) or (:adl append name:) needs to be present in the target page.

Template markup

The following replacements are applied to the template string, before inserting the data into the target page:

is replaced by the value of the form input field named name
is replaced by the result of the PHP function date("format"), which allows formatted printing of the current date.
is replaced by the result of the PHP function strftim("format"), which also allows formatted printing of the current date, but also supports translated strings like "Montag" instead of "Monday"".
is converted into a new line.

Delete Markup

The following directives can be inserted into the template. Both create a button named "Delete" that will, when clicked, delete parts of the wiki page:

(:adl delete:)
This directive deletes its own line of PmWiki markup, when clicked.
(:adl delrange:)
This directive deletes a range of multiple lines from the wiki page. The range is defined by the marks #adl begin# and #adl end#. When you want to add and delete entries with multiple lines, you should insert #adl begin# at the very beginning and #adl end# at the very end of the template. The tags will be invisible when looking at the page. Markup that has to be at the beginning of a line (like "!" for headings) still works, if it is written directly after the #adl begin#. An example template using this markup might be
#adl begin#!Topic: {topic}


----#adl end#  

which would have exactly the same layout and functionality as

!Topic: {topic}



Topic: {topic}


but mark the beginning and the end of the entry

CSS definitions

From version 2.0.2 (or 2.0unstable3) on, the form defining the delete button, has the CSS-class adldeletebutton. The default style definition for the class is

.adldeletebutton {
   display: inline;
.adldeletebutton input {
   font-size: 80%;

to ensure that the button is not standing on its own line. You can change this style by changing the value of HTMLStylesFmt['adddeleteline2'] in your local/config.php .

Known issues

  • With $RequireAuthor enabled: If the form has an 'author' field which is left empty, the edit form will pop up after submitting the form. The same is true, if no 'author' field is present and no cookie is set in the browser either. A solution may be to insert a default value for the author, or a hidden field, if no author should be entered.

Unstable release

The file adl2-unstable.phpΔ is the current unstable release. It contains the following changes that are not thouroughly tested yet.

  • Support for multiple fields with the same name throught the template markup {name[]}, which results in one entry per field. The code of Martin Fick was integrated here.
  • The Template Engine has been moved into its own function (AdlTemplateEngine) which may be helpful, if someone wants to use it for different purposes.
  • An additional directive (:adl deletelink:) creates a link with the functionality of the delete button. It uses javascript and rel=nofollow to prevent search engines from "licking" this link. Thanks to Petko Yotov.

Release Notes

2.0.2 (October 3, 2006)
Delete-button is CSS-display: inline; by default
2.0.1 (September 27, 2006)
Minor Bugfix for (:adl delete...:) in the last line without trailing \n
2.0 (September 25, 2006)
Stable release (no changes from 2.0beta9)
2.0beta9 (September 24, 2006)
Bugfix for TemplatePages: Use Keep() to prevent PmWiki from markuping the page template.
2.0beta8 (September 24, 2006)
Code beautification by Martin Fick (urlencode in AdlTemplateMarkup replaced by htmlentities
2.0beta7 (September 24, 2006)
Consequently renamed every variable now. 2.0beta6 is broke, when using >>style<< in the template string
2.0beta6 (September 23, 2006)
No change in functionality, just renamed some variables to make more sense.
2.0beta5 (September 23, 2006)
Added implicit names #top and #bottom
2.0beta4 (September 22, 2006)
Bugfix:Check get_magic_quote when adding and stripping slashes. Use PSS in preg_replacements
2.0beta3 (September 22, 2006)
Bugfix:Addslashes added also when performing a delete
2.0beta2 (September 22, 2006)
First working version of AddDeleteLine2

For the unstable release, there will be no release notes at this location. Features may be described above, and changes may be discussed on the mailing list. When the changes are tested and discussed, there will be a new stable release.

See Also


Upgrading from AddDeleteLine 1.x

If you upgrade from AddDeleteLine 1.x to AddDeleteLine2, you should first try the automated tool. If this doesn't work, the manual steps are described below.

Automated upgrade

Install AddDeleteLine2 and remove AddDeleteLine 1.x from your config. Download adlupgrade.phpΔ into your cookbook/ directory and add include_once('cookbook/adlupgrade.php') to your config.php.

Then go to the pages that contains an AddDeleteLine-Form or (:delete:) statements. Every markup that was used in the old version should now have become a button saying: "Click here to upgrade markup to AddDeleteLine2". Click this button and exactly that should happen. You should probably verify the upgraded page according to the text below.

Manual upgrade

The markup of AddDeleteLine 2.x differs completely from the markup used in the 1.x version. However the replacements are straight forward. The following table presents the markup of the old version and the replacement markup of version 2.x

Adl1 markupAdl2 markupNotes
(:form xxx:)(:adl form xxx:) 
(:endform:)(:adl end:) 
(:textfield xxx:)(:input text xxx:)Forms#standardinputcontrols
(:submit xxx:)(:input submit ok xxx:)Forms#standardinputcontrols
(:appendas "xxx":)(:adl template "xxx":) 
(:addhere xxx:)(:adl append xxx:) 
(:prependhere xxx:)(:adl prepend xxx:) 
(:delete:)(:adl delete:)only inside (:adl template "xxx":), see below

Updating the (:delete:) directive

In AddDeleteLine2, when during the template processing, the (:adl delete:) directive is replaced by (:adl delete uid Group.PageName:). When you upgrade from AddDeleteLine 1.x to AddDeleteLine2, you have to perform this replacement manually. In short:

  1. Find any (:delete:) statement in lines that have been added to the page in the past.
  2. Think of a unique number uid (counting from 1 to X will do).
  3. Replace the (:delete:) by (:adl delete uid Group.PageName:). Make sure, that there is no whitespace between Pagename and :)

Confirming deletion

For a simple way to force users to confirm that they really want to delete an entry, find the line (~89):

<input type='submit' name='doit' value='Delete'>
And change it to:
<input type='submit' name='doit' value='Delete' 
 onclick=\"return confirm('$[Are you sure you want to delete this column?]');\">
NickBell 15th April 2007


See discussion at AddDeleteLine2-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.