|
Cookbook /
PTVReplaceSummary: Add link markup or input forms to replace values in PageTextVariables
Version: 2007-04-26
Prerequisites: pmwiki 2.2.0 beta
Status: beta
Maintainer:
Categories: Editing, PageVariables
Download: ptvreplace.phpΔ
Questions answered by this recipeHow can I change Page Text Variables easily using links or forms? DescriptionDownload ptvreplace.phpΔ, copy to cookbook folder and install in local configuration file with: include_once("$FarmD/cookbook/ptvreplace.php");
This script enables replacing of page text variable (PTV) values in PTVs of form
Markup syntax for replace links: (:ptvreplace name=PTVName val=VALUE:)
Use " " for strings with spaces, like val="Value String" Optional parameters:
By default no redirection to a TargetPage takes place. $PTVRedirect = 1;
By default PTV replacing is enabled for other pages. $EnablePTVReplaceTarget = 0;
The replacement action can be done with ptvreplace link markup, and also with Input forms, using action ptvreplace. ExamplesCreating a toggle link to toggle a PTV value(:ToDo:0:) ToDo - {$:ToDo}
(:if eq {$:ToDo} 1:)(:ptvreplace name=ToDo val=0 label=Cancel:)
(:if eq {$:ToDo} 0:)(:ptvreplace name=ToDo val=1 label="To do":)
(:if:)
Changing 2 PTVs with input radio buttonsUsing input controls you can change any number of PTVs in one action. You can use radio button, text fields, select drop-down boxes etc. (:State:1:) State - '''{$:State}'''
(:Val:red:) Val - '''{$:Val}'''
(:input form name=form1 "{$PageUrl}":)(:input hidden action ptvreplace:)
(:input radio State 1 checked:) State 1
(:input radio State 2:) State 2
(:input radio State 3:) State 3
(:input radio Val "red" checked:) Val red
(:input radio Val "green":) Val green
(:input radio Val "blue":) Val blue
(:input submit post Change:)
(:input end:)
Dummy form: NotesWhen creating input controls to change several PTVs in one action, it is important that the PTVs are of the same format. Otherwise undesired replacements may occur. Release Notes
CommentsHello, is it possible to combine this with Fox? I would like to create a form with which to add some PageTextVariables and to replace some others. If I add (:input hidden action ptvreplace:) to the fox form, it changes the variables I want but doesn't add the new ones from the fox template. Thank you. Nick 19.12.2007 Fox does ptv replacements without this recipe and without extra filter function. You need to set ptvtarget=TARGETPAGENAME (can be a list) in the See AlsoSetPageTextVariable Set a PageTextVariable in PHP Contributors |