The complete syntax of loops

Loops, like tags, have a syntax which allow them to deliver content in various combinations. Optional parts are displayed only once (not for each element) and only if the loop returns some content. An additional alternative part is displayed only if the loop does NOT return any actual content. Here is the complete syntax of a loop (x is the loop’s name):

    Display this once, before the loop's content
    Display something for each matching element
    Display this only once, after the loop's content
    Display this if there are no matching element results


This loop selects the five most recently published articles on the site. In this example, the <ul> and </ul> HTML tags will be displayed only once, and only if the loop criteria match some elements. If there are no matching elements, then these optional parts will not be output. This prevents the resulting HTML file from containing the <ul> and </ul> pair of tags without any constituent <li>...</li> child elements.

<BOUCLE_latest_articles(ARTICLES){!par date}{0,5}>
  <li>#TITRE, <em>[(#DATE|affdate)]</em></li>

The #DATE tag displays the publication date of the article and the affdate filter ensures that it is in the correct language and is properly formatted.


  <li>Content of exec file (squelette), <em>13 October 2009</em></li>
  <li>AJAX links, <em>1st October 2009</em></li>
  <li>Force language according to visitor, <em>27 September 2009</em></li>
  <li>Definition, <em>27 September 2009</em></li>
  <li>List of current pipelines, <em>27 September 2009</em></li>

Author Thomas Sutton Published : Updated : 04/06/10

Translations : English, Español, français