|
Cookbook /
FoxEditSummary: add edit links for editing page sections and PTVs with Fox
Version: 2012-02-25
Prerequisites: PmWiki 2.2.0, Fox
Status: stable
Maintainer: HansB
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? DescriptionFoxEdit is an add-on for the Fox form processors by which you can add edit links. Special Fox edit forms can be called by such links, which need Fox for processing the submitted content. So FoxEdit does not do the editing, that is up to the Fox form processor! 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 = '
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 Site.FoxEditFormscopy and paste following text in green box to new page Site.FoxEditForms Fox Edit Formsfor use with Cookbook:FoxEdit and Cookbook:Fox #ptv PTV Edit Form (for a single PTV section)
[[#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] –+]
[[#ptvend]]
#section Section Edit Form
[[#section]]
(:foxmessages:)(:noheader:)(:noright:)
(: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=120 rows=15 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] –+]
[[#sectionend]]
#popupsection Section Edit Form with Popup Previewrequires Cookbook:Toggle to be installed
[[#popupsection]]
(:nolinebreaks:)(:noheader:)(:noright:)(:notitle:)
%rfloat%(:if enabled Toggle:)(:toggle id=edithelp init=hide show='$[Show Help]' hide='$[Close Help]' button:)(:if:)
(:foxmessages:)
(:div id=wikiedit:)
(: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=#226BAF%{$EditTarget}(:else:)!!!$[Editing section]: [[{$EditTarget}]] %color=#226BAF%{$EditSection}(:if:)
(:input submit post $[Save]:) (:input submit preview $[Preview]:) (:input submit cancel $[Cancel]:) Author: (:input text author value='{$Author}' size=30 class=inputtext:)\\
(:e_guibuttons:)
(:input textarea id=text name=text style='width:95pct' cols=120 rows=20 class=inputtext:)
(:input hidden access {$Accesscode}:)(:input hidden accesscode {$AccessCode}:)
(:input submit post $[Save]:) (:input submit preview $[Preview]:) (:input submit cancel $[Cancel]:)
(:foxend editform:)
(:divend:)[[<<]]
(:if [ !enabled Toggle ]:)
(:include Site.EditQuickReference:)
(:if foxpreview:)
(:div1 id=editpreview:)
>>transparency<<
>><<
(:div2 id=previewbox:)
>>previewheader<<
->[++$[Preview]++] — '''%red%$[Page is unsaved]%%''' — (:if [ foxpreview && enabled Toggle ]:)(:toggle id=editpreview init=show hide='$[Close Preview]' button:)
(:if foxpreview:)
>>previewcontent<<
(:foxdisplay:)
>>previewfooter<<
->'''$[End of preview] — %red%$[remember to save]%%''' — '''[[#top | $[Top] ]]''' — (:if [ foxpreview && enabled Toggle ]:)(:toggle id=editpreview init=show hide='$[Close Preview]' button:)
>><<
(:if foxpreview:)
(:div2end:)
(:div1end:)
(:if [ enabled Toggle ]:)
(:include Site.Popup-EditQuickRef:)
[[#popupsectionend]]
#message Message Edit Form
[[#message]]
%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] –+]
[[#messageend]]
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 section edit linksFox and FoxEdit can perform section edits, when anchors are added to the top of each section, and a FoxEdit link calling the id of the section. Links are constructed dynamically from anchor markup added above each editable section. Edit links will only be displayed if edit authorisation is given (not for visitors not logged in as editors). The anchor syntax is the standard PmWiki anchor syntax, but the name should consist of one or more letters followed by a minus sign followed by one or more digits. You can turn this feature off by setting $EnableFoxSectionEditLinks = false;
Adding edit links to FoxForum posts
$FoxEditPTVSectionForm = '
This will add edit links to new posts, but not to existing posts. Checking for simultaneous edits - Not ready, still working on this!
This check will only involve the actual page section being edited, other page sections can be edited simultaneously without triggering such warning. If one or several PTVs are edited, only the PTVs being edited will be checked. For this to work, the editform needs to contain the ptvfields= parameter, naming the PTVs being edited (this is the case with the standard edit forms). An alternative checking could be made by checking the time of the last page modification again the time the edit form was opened. Such check will catch any edits on the page, not just edits concerning the section or PTVs being targeted. For this more general time check one needs to add to the fox edit form a hidden input field like this, which catches the time the edit form opens: (:input hidden basetime {(ftime %s)}:)
Release Notes
See AlsoContributorsCommentsSee discussion at FoxEdit-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. |