adi_gps – Extract GET & POST variables

This plugin extracts GET/POST variables and assigns them to TXP variables.

Attributes

name="var name"

- a comma separated list of GET/POST variables to extract. Default = “” (extract all GET/POST variables). See type attribute for restricting retrieval to POST variables only.

new="var name"

- create a differently named variable. Default = “” (replicate variable name). Only applies when retrieving a single GET/POST variable.

type="var type"

- type of variable to extract. Default = “all” (extract GET & POST variables). Use type="post" to extract POST variables only.

quiet="boolean"

- don’t display variable value. Default = “0” (display variable value). Only applies if retrieving a single GET/POST variable. Quiet mode automatically switched on if retrieving multiple variables.

escape="mode"

- escape HTML entities in variable value. Default = “html” (escape HTML entities). Use escape="" to switch off.

decode="boolean"

- decodes any remaining %## encoding in the variable values. Default = “0” (No). Not normally required but may be needed if URL has been processed by htaccess.

glue="separator"

- separator to use when retrieving checkbox values. Default = “,” (comma).

post="boolean"

- attribute deprecated and ignored. Default behaviour (v0.2+) now extracts both GET & POST vars. Use type="post" if you want to extract POST variables only.

Examples

<txp:adi_gps />

- extract all GET/POST variables and duplicate them as TXP variables. No values are displayed.

<txp:adi_gps type="post" />

- extract only POST variables and duplicate them as TXP variables. No values are displayed.

<txp:adi_gps name="myvar1" />

- extract a single GET/POST variable called myvar1, create a TXP variable of the same name and display it’s value.

<txp:adi_gps name="myvar2" new="newvar2" />

- extract a single GET/POST variable called myvar2, but create it as a TXP variable called newvar2, and display it’s value.

<txp:adi_gps single name="myvar3" quiet="1" />

- extract a GET/POST variable called myvar3, create a TXP variable of the same name but don’t display it’s value.

<txp:adi_gps name="myvar1,myvar2,myvar3" />

- extract three named GET/POST variables, where TXP variables of the same name are created, but no values displayed.

Retrieving multiple values from checkboxes

For example, if you have the following form:

<form>
	<input name="multiple[]" type="checkbox" value="first"/>First<br>
	<input name="multiple[]" type="checkbox" value="second"/>Second<br>
	<input name="multiple[]" type="checkbox" value="third"/>Third<br>
	<input type="submit" value="Submit" />
</form>

and a user ticks the first and second checkbox, then the TXP variable called multiple will contain “first,second”. The comma is the glue which can be changed using an attribute.

Using the GET/POST variables in pages or forms

Because, by default, adi_gps duplicates the extracted URL variables as TXP variables you can use all the standard TXP variable tags to process them:

  • <txp:variable />
  • <txp:if_variable />

For example:

<txp:adi_gps name="myvar" quiet="1" />
<txp:if_variable name="myvar" value="some_value">
    do something different ...
<txp:else />
    the same old thing ...
</txp:if_variable>

Using URL variables in articles

You can also use <txp:adi_gps /> within articles. For example:

The value of myvar is <txp:adi_gps name="myvar" />

or if you’ve already extracted the variable elsewhere:

The value of myvar is <txp:variable name="myvar" />

No escaping from Textile is required (e.g. using notextile. or == ... ==).

Version 0.3 - Download (Uncompressed) Support