#GET

#GET{variable} is used to retrieve the value of a local variable that was stored using a #SET{variable, value}. See also #SET.

A second argument is used to return a default value if the parameter requested does not exist or if its content is empty.

#GET{variable, default value}

Example

If "use_documentation" equals "yes", make it known:

#SET{use_documentation,yes}
[(#GET{use_documentation}|=={yes}|oui) 
	We use documentation!
]

Display a link to the site’s home page over an image called "my_logo.png" if there is one, otherwise use "logo.png", otherwise use the site logo:

[(#SET{image,[(#CHEMIN{my_logo.png}
	|sinon{#CHEMIN{logo.png}}
	|sinon{#LOGO_SITE_SPIP})]})]
[<a href="#URL_SITE_SPIP/">(#GET{image}
	|image_reduire{100})</a>]

Differentiate the absence of an element in the environment: define #ENV{default} as a default value when #ENV{activer} does not exist. To do this, the is_null filter allows us to test that #ENV{activer} is not defined. If #ENV{activer} exists but is empty, it will be used. We can thereby differentiate the case of sending an empty value into a form, as shown below when the value sent is that of the "champ_activer_non" input field

[(#SET{valeur,[(#ENV{activer}
	|is_null|?{#ENV{defaut},#ENV{activer}})]})]

<input type="radio" name="activer" id="champ_activer_oui"[ (#GET{valeur}|oui)checked='checked'] value='on'  />
<label for="champ_activer_oui"><:item_yes:></label>

<input type="radio" name="activer" id="champ_activer_non"[ (#GET{valeur}|non)checked='checked'] value='' />
<label for="champ_activer_non"><:item_no:></label>

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français, Nederlands