Tags available throughout the site

The following tags can be used in any template page on a SPIP site, even on those that do not have loop or other mechanism to provide an object "context".

Tags defined on the “Site configuration” pages

The contents of these tags are defined in the editing area when you configure your site.

-  #NOM_SITE_SPIP displays the name of the site.

-  #URL_SITE_SPIP displays the address of your site. As the tag does not include the final slash “/”, you can create a complete absolute page link by coding something like #URL_SITE_SPIP/sommaire.php.

-  #DESCRIPTIF_SITE_SPIP, this tag is used to display the site description as it has been entered on the configuration page.

-  #EMAIL_WEBMASTER is the webmaster’s email address. By default, SPIP takes the address of the first administrator, i.e. the one who installed the site. If you would prefer to use a “Write to the webmaster” form, see “Forms”.

-  #LOGO_SITE_SPIP In fact it is the logo of the root section of the site, section 0.

-  #CHARSET , this tag returns the character encoding used by your site. Its default value is iso-8859-1, i.e. “ISO-Latin-1”. For an introduction to charsets, see Character encodings.

-  #LANG , when used outside any ARTICLES, RUBRIQUES, BREVES and AUTEURS loops, will return the principal language of the site.

-  #LANG_DIR, #LANG_LEFT, #LANG_RIGHT introduced these tags which define the writing direction of the current language. See: Creating a multilingual site for further details.

-  #MENU_LANG (and #MENU_LANG_ECRIRE) display a language menu allowing a visitor to switch to the current page in the chosen language. The first tag displays the list of languages used on the site, the second is the list of languages of the private area (this list is used on the login screen).

Layout tags

-  #DOSSIER_SQUELETTE This provides the path to the folder in which the template is installed.

In this way, you can place the "accessory" files (style sheet, javascript, etc.) for the template in the template directory and simply distribute this folder to exchange templates. So, for example, to include a stylesheet in the template directory, we would write:

<link rel="stylesheet" href="#DOSSIER_SQUELETTE/my_style.css" type="text/css" />

-  The tag #CHEMIN returns the complete path to a file xxx, whether this file is at the root of the site, in the templates directory, in dist/, etc. Use like this, for example:

<link rel="stylesheet" href="#CHEMIN{my_styles.css}" type="text/css" />

-  #PUCE displays a bullet like the one on the left.

-  #FORMULAIRE_ADMIN is an optional tag used to change the position on the public site of the administration buttons (“Refresh this page”, “Modify this article”, etc.) which are only visible to logged-in administrators. If this tag is in the template, the administration buttons will be displayed in the chosen place, otherwise they will be displayed at the end of the page.

-  #DEBUT_SURLIGNE, #FIN_SURLIGNE are tags which indicate to SPIP in which part of the page to highlight words which have been found by a search loop. See: "The search loops and tags".

-  The tag #INSERT_HEAD can only be used in templates between the HTML tags <head> and </head>. It allows SPIP and plugins (if any are installed) to add lines in to the head section of the HTML page.

Technical tags

N.B. These tags are for experienced users of SPIP only.

-  The #REM tag does not display anything. It makes it possible to place comments inside your template files: [(#REM) This is only a comment. ]. Such comments do not appear in the source code of the pages produced for the site either.

-  #SELF returns the URL of the current page starting from the site root. Any variables only added for SPIP’s internal use are removed. For example #SELF inserted in a page which is called with this URL:
would return: article.php?id_article=25

The #SELF tag can be useful in forms. Example:

<form action="#SELF" method="get">

(Note: #SELF is not compatible with the use of <INCLURE()> (unless the $delais or #CACHE of the included template is set to 0).

-  #URL_PAGE this tag returns a "page" type URL (see: Using personalised URLs) for use in a link, using the template passed as a parameter. For example to use the template mypage.html, in your templates directory, use #URL_PAGE{mypage}, which will generate a URL of this form: spip.php?page=mypage. A second parameter can be used to add parameters, e.g.: #URL_PAGE{mypage,id_article=#ID_ARTICLE} will generate: spip.php?page=mypage&id_article=XXX.

-  #ENV{xxxx,zzzz} returns the variable named xxxx which has been passed in the HTTP request (i.e. a GET or POST variable). It may be a criterion specified in <INCLURE>). zzzz is an optional part which specifies a default value if the variable xxxx does not exist.

By default, #ENV returns a value filtered by htmlspecialchars. This can be overridden in the usual manner by adding an asterisk to the tag: #ENV*{myvariable}.

Example — In order to set limits to a list of authors:

<BOUCLE_auteurs(AUTEURS) {nom == #ENV{firstletter,^A}}>

This loop will display the list of authors who have names corresponding to the regular expression specified in the URL by the variable firstletter (for example, author_list.php?firstletter=^Z) or else, if there is no such variable in the URL, it will display the authors whose names begin with “A”.

-  The #SPIP_CRON tag has an effect upon the calculations which SPIP carries out behind the scenes to update statistics, the search engine, site syndication, etc. If the tag is not present on the site, SPIP performs these calculations when necessary, after sending a page to a visitor. Unfortunately, PHP does not allow for closing the connection at the end of the page and in some cases, when a longer background task has been triggered — syndication, in particular — there can be a noticeable delay in the page being displayed.

The #SPIP_CRON tag averts this problem. It generates an invisible <div> with a background property pointing to the script spip_background.php. This script executes the necessary calculations as “background tasks” and sends back a transparent, 1x1 pixel image. This trick alleviates the sense of being held up, by transferring any slowness to a subsidiary script.

N.B. This tag is not essential, and its presence or absence does not change the execution frequency of the site’s calculation tasks.

-  #SET{ variable,value } and the corresponding tag #GET{variable} . #SET{xxx,yyy} assigns the value yyy to the variable xxx limited to the template in which it is placed. This value can be read by the tag #GET{xxx}. Variables created in this way are not passed to included templates.

N.B. If you assign a value to a variable in the the preceding optional part of a loop, it is not possible to use the variable within the main body of the loop. This is due to the manner in which SPIP calculates templates.

-  #HTTP_HEADER{argument} makes it possible to modify HTTP headers in SPIP pages. Example: #HTTP_HEADER{Content-Type: text/css}. N.B. The use of this tag causes the disappearance of the admin buttons. It is not possible to use this tag in templates included with <INCLURE>.

-  #EVAL{argument} evaluates the PHP expression placed within the braces. For example, #EVAL{1+1} will display 2, #EVAL{_DIR_IMG_PACK} will display the path to the directory ecrire/img_pack/. N.B. You are strongly advised to use this tag sparingly.

-  #CACHE{time}, this tag sets the duration for which the page will be kept in cache. The time is in seconds and can be expressed as a calculation For example: #CACHE{24*3600}.

-  The #SQUELETTE tag, displays the full path name for current template file. This is useful for checking which of several possible files with the same name stored in different directories has taken preference over the others - particularly useful when overriding model and template code provided by a plugin.

-  The #VAL{argument} tag returns the argument bassed between the braces. For example: #VAL{toto} returns "toto".

Author bealach, Paolo Published : Updated : 01/07/23

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