Delete Links

Summary: add delete links for deleting lines or sections with Fox Version: 2019-11-11 Prerequisites: Pmwiki 2.2.56 and later, Fox. (PHP 5.5 and 7.2 compatible) Status: beta Maintainer: HansB? Categories: Forms Fox Download: see Cookbook:FoxDelete

Questions answered by this recipe

How can I add delete links or buttons with which to delete lines or sections?

Description

An add-on for the Fox form processor which enables line or section delete links and buttons.

Install in the usual manner by copying to cookbook/ or cookbook/fox/ folder and including in local config file.

This script adds template markup {[foxdelline]}, {[foxdelrange]}, {[foxdelline button]} and {[foxdelrange button]} which can be used in a Fox template to create a delete link or button to delete a line or posted content section.

Note that the markup is for fox templates only! The delete link or button form gets created via a Fox posting. Thereby Fox adds an id number to the link and button, which makes it possible to target the line or section for deletion in which the link or button is situated. Sections are marked by using #foxbegin# and #foxend# markers in the template.

New: Markup {[foxdelpage <targetname> ]} and {[foxdelpage button <targetname> ]} allows page deletion. <targetname> can be either full page name, or name of page for current group. It should be allowed for deletion via the $FoxPagePermissions variable. The foxdelpage markup can be used outside fox templates, it does not use special line keys for identifying lines or sections for delete. If you use a custom delete key pattern (other than the PmWiki standard), you should set in config.php variable $FoxPageDeleteKey to the string you are using for deleting pages. A redirect=<pagename> parameter can be set, to redirect to another page after page gets deleted.

Generally disable fox page deletion or line/range deletion in config

$EnableFoxPageDelete = false;
disable deletion of pages and suppress the links.
$EnableFoxPostDelete = false;
disable deletion of lines and ranges, and suppress the links.

Examples

The following will add a line of input text with a foxdelete (line) link for line deletion above the foxappend marker, thereby following additions are added below previous ones (use (:foxprepend frm:) to achieve the opposite, i.e. latest on top):

(:fox frm1 :)
(:foxtemplate "*  {[foxdelline]}":)
(:input text comment size=50:)
(:input submit post 'Add Comment':)
(:foxend frm1:)

(:foxappend frm1:)

The following will add a section of text to the page, with a foxdelete (range) link for deleting the whole section:

(:fox frm2 template=commenttmpl:)
(:input textarea comment rows=6 cols=50:)
(:input submit post 'Add Comment':)
(:foxend frm2:)
(:if false:)
[[#commenttmpl]]
#foxbegin#
----
%rfloat%{[foxdelrange]}

#foxend#
[[#commenttmplend]]
(:if:)

Note the template uses #foxbegin# and #foxend# markers for identifying the delete range.
The template here is defined on the same page, but can be equally or better defined on a separate template page, like Site.FoxTemplates. (:if false:)...(:if:) is used to suppress the template from being shown in the page.

Notes

The foxdelete markup and action handling function was previously included in fox.php.

Release Notes

  • 2019-11-11: Re-added page delete capability, which got lost in previous version.
  • 2017-06-16: replaced Markup_e() calls with Markup() calls, for PHP 7.2 compatibility.
  • 2015-01-10: Fixed bug in rendering of tooltip
  • 2015-01-08: Simplyfied markup for page delete.
  • 2015-01-07: Added page delete capabilities.
  • 2014-02-21: Fixed markup definition to be PHP 5.5 compatible.
  • 2008-04-19: Modified markup definition and added option tooltip='STRING'.
  • 2008-03-16: Changed handling of $FoxAuth so customisations applied after foxdelete.php is included will be honoured. Moved delete warning messages from fox.php to foxdelete.php
  • 2008-02-07a: Modified which edit functions are called.
  • 2008-02-07: Fixed bug which prevented ChangeSummary to appear in page history.
  • 2008-02-05: Added handling of $ChangeSummary, so any value from an input field named 'csum' will be written into the page attributes and be available for the page history.
  • 2008-01-09: Initial release. Previously part of fox.php. Still part in the older Fox version Attach:fox-1.php Δ

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See Also

Contributors

Comments


<< Edit Links | Index | Notes >>