Optional criteria with operators

The use of optional criteria may be combined with the use of operators under certain specific conditions. In particular, it is necessary for the variable which is being tested in the environment to have the same name as the criteria; for example, X in:
{X ?operator #ENV{X}}. Any operator can be used here, and you only need to affix a ? to the selected operator (leaving no space between the ? and the operator).

In the following examples, the test is performed only if the variable is present in the environment. Otherwise the criterion is ignored.

  1. <BOUCLEx(TABLES){myvar ?operator #ENV{myvar}}>
  2. <BOUCLEx(TABLES){myvar ?== ^#ENV{myvar}$}>
  3. <BOUCLEx(TABLES){myvar ?!IN #ENV{myvar}}>
  4. <BOUCLEx(TABLES){myvar ?LIKE %#ENV{myvar}%}>...

Download

Example

To select the 10 most recent articles but with an "earlier publishing date" prior to the one in the current environment, or, failing that, simply the 10 most recent articles, use this loop:

  1. <ul>
  2. <BOUCLE_art(ARTICLES){date_redac ?< #ENV{date_redac}}{!par date}{0, 10}>
  3. <li>#TITRE</li>
  4. </BOUCLE_art>
  5. <ul>

Download

Author Paolo Published : Updated : 17/06/10

Translations : English, français