|
Cookbook /
FoxEditSummary: add edit links for section and PTV edits
Version: 2008-07-14
Prerequisites: pmwiki 2.2.0 beta, Fox
Status: new
Maintainer: HansB
Download: foxedit.phpΔ
Discussion: FoxEdit-Talk
Questions answered by this recipeHow can I add edit links which will open an edit form to edit a page section or PTVs? DescriptionAn add-on for form processors like Fox to add edit capabilities Install in the usual manner by copying to cookbook/ or cookbook/fox/ folder and including in local config file. This script adds a markup
There are two default edit forms, configurable with setting variables:
Please make sure you have these forms installed, or set variables to custom forms you use! $FoxEditPTVSectionForm = 'FoxTemplates.EditMessageForm';
Three page variables are defined which can be used in the edit form:
A custom markup is included by which an anchored section of form The form examples shown here have some additional line breaks, in order to preserve the ski layout. Remove as necessary for your wiki page! Example: FoxTemplates.EditSectionForm: Form to edit anchored sections (:foxmessages:)
(:if foxpreview:)
!!!$[Preview]: %green%[-–
$[Changes have not been saved] –-]
>>frame<<
(:foxdisplay:)
>><<
(:if:)
(:fox editform foxaction=replace put=overwrite target={$EditTarget}{$EditSection}
redirect={$EditTarget}{$EditSection}:)
(:foxtemplate "{$$text}":)(:input default request=1:)
(:input hidden csum 'Section {$EditSection} edited':)
(:if equal {$EditSection} '':)!!!$[Editing page]: %color=#009%{$EditTarget}
(:else:)!!!$[Editing section]: %color=#009%{$EditSection}(:if:)
|| ||(:guibuttons:)||
|| ||(:input textarea id=text name=text style='width:95pct'
cols=90 rows=12 class=inputtext:) ||
(:input hidden access {$Accesscode}:)(:input hidden accesscode {$AccessCode}:)
|| ||Author: (:input text author value='{$Author}' size=30 class=inputtext:)
(:input submit post $[Save]:) (:input submit preview $[Preview]:)
(:input submit cancel $[Cancel]:) ||
(:foxend editform:)
(:if foxpreview:)
%green center%[+– $[Changes have not been saved] –+]
Example:FoxTemplates.EditPTVForm: Form to edit a single PTV (:foxmessages:)
(:if foxpreview:)
!!!$[Preview]: %green%[-–
$[Changes have not been saved] –-]
>>frame<<
(:foxdisplay:)
>><<
(:if:)
(:fox editform ptvtarget={$EditTarget} ptvfields={$EditSection} redirect=1:)
(:foxpreviewtemplate "{$$ptv_{$EditSection}}":)
(:input hidden csum 'Section {$EditSection} edited':)
(:if foxpreview :)(:input default request=1:)(:else:)
(:input default source={$EditSource} :)(:ifend:)
!!!$[Editing PTV]: %color=#009%{$EditSection}
||(:guibuttons:) ||
||(:input textarea id=text name=$:{$EditSection} cols=80 rows=12 class=inputtext:) ||
(:if enabled EnableAccessCode:)
||Enter value {$AccessCode} (:input text access size=3 class=inputtext:)
(:input hidden accesscode {$AccessCode}:) <- Have you entered the code number? ||
(:if enabled EnablePostCaptchaRequired:)
||Enter value {$Captcha} (:input captcha class=inputtext:)
<- Have you entered the code number? ||
(:if:)
||Author: (:input text author value='{$Author}' size=30 class=inputtext:)
(:input submit post '$[Save]':) (:input submit preview $[Preview]:)
(:input submit cancel '$[Cancel]':) ||
(:foxend editform:)
(:if foxpreview:)
%green center%[+– $[Changes have not been saved] –+]
See FoxContacts for an application which uses a custom edit form to edit the fields of a contacts info page. NotesEdit Forms with Preview buttonMake sure of the following:
The form examples on this page have been updated to include Preview, and the FoxForum zip file contains page files in its templates.d folder for ready use.
Adding edit links to FoxForum posts
$FoxEditPTVSectionForm = 'FoxTemplates.EditMessageForm';
%red%(:foxmessages:)(:if foxpreview:)
!!!$[Preview]: %green%[-–
$[Changes have not been saved] –-]
>>frame<<
(:foxdisplay:)
>><<(:ifend:)
(:fox editform ptvtarget={$EditTarget} redirect=1 :)
(:input hidden csum 'Section {$EditSection} edited':)
(:foxpreviewtemplate "'''{$$ptv_subject{$EditSection}}'''
\n----\n\n{$$ptv_message{$EditSection}}":)
(:if foxpreview:)(:input default request=1:)(:else:)
(:input default source={$EditSource} :)(:ifend:)
!!!$[Edit Message]: %color=#009%{$EditSection}
|| Subject:||(:input text name=$:subject{$EditSection} size=70:) ||
|| ||(:guibuttons:)||
|| Message:||(:input textarea id=text name=$:message{$EditSection}
cols=80 rows=12 class=inputtext:) ||
(:if enabled EnableAccessCode:)
|| ||Enter value {$AccessCode} (:input text access size=3 class=inputtext:)
(:input hidden accesscode {$AccessCode}:) <- $[Have you entered the code number?]||
(:if enabled EnablePostCaptchaRequired:)
|| ||Enter value {$Captcha} (:input captcha class=inputtext:) <-
$[Have you entered the code number?]||
(:if:)
|| Author:||(:input text author value='{$Author}' size=30 class=inputtext:)
(:input submit post '$[Save]':) (:input submit preview '$[Preview]':)
(:input submit cancel '$[Cancel]':) ||
(:foxend editform:)
(:if foxpreview:)
%green center%[+– $[Changes have not been saved] –+]
This will add edit links to new posts, but not to existing posts. Release Notes
See AlsoContributorsCommentsSee discussion at FoxEdit-Talk |