SPIP

[ar] [ast] [bg] [br] [ca] [co] [cpf] [cs] [da] [de] [en] [eo] [es] [eu] [fa] [fon] [fr] [gl] [id] [it] [ja] [lb] [nl] [oc] [pl] [pt] [ro] [ru] [sk] [sv] [tr] [vi] [zh] Espace de traduction

Download

|parametre_url

July 2010 — updated on : January 2011

All the versions of this article:


The |parametre_url{variable name, value} filter, applied to a URL type tag (e.g. #SELF, #URL_ARTICLE, #URL_PAGE{sommaire}...), will add or remove a parameter to that URL.

For example:
[(#SELF|parametre_url{country, France})] will add to the current page’s URL either ?country=France if it is the first parameter passed in the URL or &country=France if the URL already has at least one other parameter.

Such tags are typically included in the href part of a link definition: <a href="[(#SELF|parametre_url{country,France})]">France</a>

To then later retrieve the value of the parameter passed in the URL, we would use the #ENV tag.
In the example above, #ENV{var1} would return France.

Passing several parameters with the URL

We can chain filters for passing a series of parameters and their values to a URL: [(#SELF|parametre_url{country,France}|parametre_url{currency,euro})].

If we want to pass the same value to several parameters, we would use this syntax: [(#SELF|parametre_url{country|location|territory, France})] which will return the current page’s URL suffixed with: country=France&location=France&territory=France.

Deleting existing parameters

To make an existing URL parameter disappear, you need to empty it’s value by declaring a new one that is explicitly empty: [(#SELF|parametre_url{country, ''})].

We can delete several parameters at one with: [(#SELF|parametre_url{country|location|territory, ''})].


Show the template of this page Site powered by SPIP | Translation area | Private area