The ARTICLES loop

An article loop is coded by placing ARTICLES (with an ’s’) in brackets.

<BOUCLEn(ARTICLES){criteria...}>

The elements contained in such a loop are articles.

The selection criteria

We will use one of the following criteria to indicate how we will select the articles:

{branche} selects all the articles in the section AND its sub-sections.

This is a kind of extension of the {id_secteur} criteria.

Searches for the item identifier in the first parameter of the criterion {branche XX}if it is filled in, otherwise, without parameter ({branche} in the parent loops. It is used to calculate the list of field identifiers for the entire branch.

The loop that has this criterion looks for a possible link with the column heading_id, and will try to find a join with another table if it is necessary to obtain it.

This criterion should be used with caution: if your site is well structured, you should not need it, except in very special cases.

-  Criteria {date} (or {date=...} or {date==...}, or code>{date<..}, etc.) allow you to select an article based on the date entered in the URL or the context.

The comparison operators can be used: ==; != ;< ; <= ; > ; >= ; The element on the right can be a tag or a date in international format: YYYY-MM-DD hh:mm:ss.

-  {id_article} selects the article specified by the identifier id_article. Since the identifier of each article is unique, this criteria only returns one or no response.

-  {id_auteur} selects the articles that correspond to the author identifier (useful for specifying the list of articles written by a given author). It is important to note that an article may be linked to several authors at the same time.

-  {id_groupe=zzzz} is used to select articles linked to a keyword group; this is the identical principle to the previous {type_mot} , but since we are working here with an identifier (the group number), the syntax is correspondingly a "cleaner" one. [Note: This criteria can not (in SPIP’s current development status) be combined with the the previous {type_mot=yyyy}]

-  {id_mot} selects articles that correspond to the keyword identifier (’mot’ in french). This is often useful to indicate a list of articles that deal with a particular subject.

-  {id_rubrique} selects the articles contained in the section ("rubrique" in French) identified by {id_rubrique}.

-  {id_secteur} selects the articles in that sector (a sector is defined as a section that is not the child of any other section, i.e. it is located at the root of the site).

-  {lang} selects articles tagged with the language specified in the page URL address.

-  {origine_traduction} selects the reference article which was the original version for this translated article. An original version of an article is its own reference version.

See also programmer.spip.org for further examples

-  {pagination} When a loop returns several dozen articles (or, for a petition, several thousand signatures), it is undesirable, if not impossible, to display everything on a single page.

-  {recherche} selects articles that match the keywords specified in the search interface (the search engine built into SPIP).

The {si ...} criterion is used to condition the execution of a loop to the condition expressed as an argument in the criterion.

-  {titre_mot=xxxx}, or {type_mot=yyyy} respectively select articles linked to the keyword that is named "xxxx", or those that are linked to the keyword group named "yyyy". If there are several such criteria {titre_mot=xxxx} (or several {type_mot=yyyy}), then SPIP will select those that have all of those words at the same time.

The {tout} criteria is used to select the data in a data as if there were no other restrictive criteria applied to that selection.
As such, its usage is often attributed as being a reminder to the webmaster of a conscious decision since the same result can usually obtained without adding this new criteria.

-  {traduction} selects the translations of the current article in the various other languages that it has been translated into.

Status of the article

Like all SPIP loops, a ARTICLES loop returns only published articles; in the case where the site is set not to publish "post-dated" articles, another test is made on the article date. Le critère {statut} permet d’autres sélections :

  • {statut IN prop,prepa,publie,refuse,poubelle} selects articles according to their publication status:
  • {statut=prepa} selects the articles editing in progress in the private area;
  • {statut=prop} selects the articles submitted for evaluation;
  • {statut=publie} selects articles published on the site, including "post-dated" articles;
  • {statut=refuse} selects articles that have been rejected for publication;
  • {statut=poubelle} selects items that have been put in the bin.

Display Criteria

Once you have specified the selection criteria, you will be able to add the following criteria to restrict the number of displayed elements.

-  The criteria common to all loops apply here.

-  {exclus} makes it possible to exclude the current article from the result set (for example, when you display the articles contained in the same heading, you may not want to display a link to the currently displayed article).

Tags of this loop

Tags retrieved from the database

The following tags represent the items retrieved from the database (as opposed to those that are “calculated” and are explained later). You can also use them as sorting criterion (for example, {par titre} by title or {par date} by date).

-  #CHAPO returns the introductory paragraph to the article, sometimes known as the ’standfirst’.

-  Dates: #DATE, #DATE_REDAC, #DATE_MODIF are documented in the dates management.

-  #DESCRIPTIF displays the description field.

-  #ID_ARTICLE returns the unique identifier of the article. Useful for building custom hypertext links to the article (for example towards a “printer friendly” page).

-  #ID_RUBRIQUE returns the identifier of the section (rubrique) to which the article belongs.

-  #ID_SECTEUR returns the identifier of the sector on which the article depends (the sector being the section located at the root of the site).

-  #LANG returns the language of the article.

-  #POPULARITE returns the popularity rating of this article as a percentage. See the documentation on the popularity of articles.

-  #PS returns the postscript of an article.

-  #SOUSTITRE returns the subtitle.

-  #SURTITRE returns the surtitre field, the top title.

-  #TEXTE returns the main text of the article.

-  #TITRE returns the title of the article.

-  #NOM_SITE and #URL_SITE display the name and url of the "hyperlink" associated with the object concerned.

-  #VISITES returns the number of visits recorded for this article.

Tags calculated by SPIP

The following elements are calculated by SPIP. They cannot be used as sorting criteria.

-  #NOTES returns the footnotes (calculated from an analysis of the text).

-  #INTRODUCTION: returns the article’s description if it exists, failing that it returns the first 600 characters of the article (introduction then text).

-  #LESAUTEURS returns the authors of this article. This makes it unnecessary to create an AUTEURS loop to obtain the same result.

-  #PETITION gives the text of the petition associated with the article (if there is one). If a petition exists, but has no text, then this tag returns a space — which is without effect in an HTML page.

-  #URL_ARTICLE is the complete URL of the article’s page.

-  #FORMULAIRE_FORUM creates the forum interface for this article

-  #FORMULAIRE_SIGNATURE creates the petition interface for this article.

-  #PARAMETRES_FORUM returns a list of the variables needed to create a link to the forum making it possible to respond to this article in the forum. For example:

[ <a href="spip.php?page=forum&(#PARAMETRES_FORUM)">Comment on this article </a> ]

Logos

-  #LOGO_ARTICLE displays the article’s logo, including the optional hovering logo if one has been included for the article.

-  #LOGO_RUBRIQUE displays the section logo of the article.

-  #LOGO_ARTICLE_RUBRIQUE displays the logo of the article, possibly replaced by the logo of the section if there is no specific logo for the article.

In addition, two tags allow you to retrieve only one of the two logos:

-  #LOGO_ARTICLE_NORMAL is the base logo
-  #LOGO_ARTICLE_SURVOL is the hovering logo.

See also: Complete syntax of the #LOGO_XXX tags

Author Paolo, Paul Knight Published : Updated : 19/04/23

Translations : عربي, català, Deutsch, English, Español, français, italiano, Nederlands, русский, українська