|
Cookbook /
RequestSummary: Extends conditional markup to test parameters in the URL, to allow pages to pass parameters via their URL links
Version: 2010-05-12
Prerequisites: Tested using Pmwiki version 2.10
Status: Beta
Maintainer: RandyB
Categories: Markup
Download: request.phpΔ
On this page: Questions answered by this recipe
DescriptionThis script provides markup to test the value of any parameter in the URL. After activating this recipe you can use ActivationTo activate this recipe, download request.phpΔ, and put it in your cookbook directory. Add the following line to your local/config.php:
include_once("$FarmD/cookbook/request.php");
UsageSyntax
For example:
If the parameter has no value (that is, "?parameter="), it is treated as if it were not present. Example of allowing multiple requestsUse the following markup:
Select part
[[{*$FullName}part=one|1]] ,
[[{*$FullName}?part=two|2]],
[[{*$FullName}?part=three|3]], or
[[{*$FullName}?part=All|All]]
(:if ( request part All ) or ( request part one ) or ( !request part ) :)
You are viewing part 1
(:if ( request part All ) or ( request part two ) :)
You are viewing part 2
(:if ( request part All ) or ( request part three ) :)
You are viewing part 3
(:ifend:)
Result: The user will see links to select parts 1, 2, 3, or All. Clicking on a link shows the requested part(s).
Example of showing debug informationYou have page MyPage with the following on it: (:if request debug 1:) This is line 1 (:ifend:) (:if request debug 2:) This is line 2 (:ifend:) Result:
Example of allowing a styling requestUse the following markup: (:if request bold:)(:div1 style="font-weight: bold;":)(:ifend:) This is shown as bold only if requested. (:if request bold:)(:div1end:)(:ifend:) Result:
Example of using the values entered on a formYou have page MyPage with the following on it
(:input form method=get:)
(:input hidden n {*$FullName} :)
(:input hidden submitted 1:)
(:input default request=1:)
Color: (:input checkbox red 1:) Red (:input checkbox blue 1:) Blue (:input checkbox green 1:) Green
Background: (:input radio background yellow:) yellow (:input radio background "":) normal
Rating of recipe: (:input select rating useful:) (:input select rating useless:)
(:input submit:)
(:input end:)
(:if1 request submitted:)(:comment --- use the entered values if the form's submit button was pressed ---:)
>>frame bgcolor={$?background}<<
(:if request rating useful:)
I'm glad you found this recipe useful.
Please [[http://www.pmwiki.org/wiki/Cookbook/Request-Users?action=edit|add yourself as a user]].
(:else:)
Sorry you found this recipe useless.
(:ifend:)
(:if2 ( request red ) or ( request blue ) or ( request green ) or ( request background ) :)
You selected:
(:if request red:) %red%red%%
(:if request blue:) %blue%blue%%
(:if request green:) %green%green%%
(:if request background yellow:) with a yellow background.
(:ifend:)
(:else2:)
You didn't select any colors!
(:if2end:)
(:if1end:)
Result: The page that the form goes to after submission (in this case the same page) uses the values that the user entered on the form.
TipsFor other ways to use URL requests, see Cookbook:HttpVariables. NotesRelease notes
See alsoContributorsCommentsUser notes +1: 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. |