#SELF

#SELF returns the URL of the called page, cleaned of any variables specific to running SPIP.

  • New in : SPIP 1.8

#SELF returns the URL for the current page. Any variables specific to running SPIP (e.g. var_mode) are deleted.

Example: for a page with the URL: spip.php?article25&var_mode=recalcul, the #SELF tag inserted into article.html will return spip.php?article25.

Usages

-  Certain form tags accept a parameter to specify what page the visitor should be redirected to after having completed the form. #SELF can then be used so that it returns back to the current page. Example: [(#FORMULAIRE_FORUM{#SELF})]

-  Using the |parametre_url filter to add variables to the URL of the current page. Example: [(#SELF|parametre_url{'id_mot','3'})] adds id_mot=3 to the current URL. See |parametre_url for more details.

-  #SELF is used in forms so that the user returns back to the current page after validating the form:

<form action="#SELF">
[(#SELF|form_hidden)]
...
</form>

The |form_hidden (SPIP 1.9) filter calculates the hidden fields of the form based on the arguments of #SELF. See |form_hidden.

SELF used in included template files

Whenever one of the parameters of the page’s URL must be retrieved from an included template file, #SELF needs to be added as a parameter to the INCLURE. This will create a different cache for the included template file for each URL [1].

<INCLURE{fond=my_template}{self=#SELF}>
<INCLURE{fond=my_template}{self}>
<INCLURE{fond=my_template}{env}>

This {self=#SELF} parameter must also be passed to an INCLURE when you want to use the #PAGINATION tag in an included template file, given as the included file relies on the self function to retrieve the value of the debut_... variable.

Footnotes

[1This constitutes a security mechanism against potential XSS attacks.

Author Mark Published : Updated : 17/07/23

Translations : عربي, català, English, Español, français, Nederlands