Coding with SPIP 3.0
SPIP3.0 Technical Documentation

> > > > Optional criteria

Optional criteria

Sometimes it’s useful to make a selection only if the environment contains the requested tag. For example, we might hope to filter the loops based on a particular search, but only if a search has been performed, otherwise display everything. In such a case, a trailing question mark is used to request such an action:

  1. <BOUCLEx(TABLES){criterion?}>...

Example

Display either all the articles of the site (if there is no id_article, id_rubrique or recherche variable apparent), or perform a selection based on the criteria that are present. In this way, if we call the template with the id_rubrique=8 and recherche=extra parameters, the loop will select only the articles that match these criteria. This allows us to reuse the loop code in different ways within a model or with SPIP template includes.

  1. <BOUCLE_art(ARTICLES){id_article?}{id_rubrique?}{recherche?}>
  2. - #TITRE<br />
  3. </BOUCLE_art>

Download

  • Author :
  • Published :
  • Updated : 30/05/10
  • Translations : English, français