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] [uk] [vi] [zh] Espace de traduction

Download

Tags available throughout the site

April 2004 — updated on : December 2010

All the versions of this article:

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 (since SPIP 1.9), 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 [SPIP 1.8] introduced this tag to reference the site logo. In fact it is the logo of the root section of the site, section 0.

-  #CHARSET (available since SPIP 1.5), 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 (introduced in SPIP 1.7, SPIP 1.7.2 ), when used outside any ARTICLES, RUBRIQUES, BREVES and AUTEURS loops, will return the principal language of the site.

-  #LANG_DIR, #LANG_LEFT, #LANG_RIGHT SPIP 1.7, SPIP 1.7.2 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) SPIP 1.7, SPIP 1.7.2 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

-  From SPIP 1.9, 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:

(Note: This tag replaces #DOSSIER_SQUELETTE which was introduced by SPIP 1.8.2.)

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

-  #FORMULAIRE_ADMIN since SPIP 1.5), this 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.
N.B. From SPIP 1.8, 1.8.1 the stylesheet spip_admin.css can be used instead to adjust the style and placing of these admin buttons.

-  #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 (snice SPIP 1.9.1) 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 SPIP 1.8 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: http://mysite.net/article.php?id_article=25&var_mode=recalcul would return: article.php?id_article=25

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

(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 (from SPIP 1.9) 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} SPIP 1.8, 1.8.1 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:

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 SPIP 1.8, 1.8.1 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} were introduced with SPIP 1.9.1. #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} (since SPIP 1.9) 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} (since SPIP 1.9) 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}, introduced in SPIP 1.9, 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, introduced in SPIP 1.9.1, 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 is introduced in SPIP 2.0, and returns the argument bassed between the braces. For example: #VAL{toto} returns "toto".


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