Comparison filters

Just like the criteria used for loops, comparison filters can also be applied to tags with the following "pipe" syntax:

  1. [(#TAG|operator{value})]

The list of applicable operators includes:

  • == (confirms equality)
  • !=
  • >
  • >=
  • <
  • <=

Example

  1. [(#TITRE|=={Chocolate}|oui)
  2. Some chocolate!
  3. ]
  4. [(#TEXTE|strlen|>{200}|oui)
  5. This text is longer than 200 characters!
  6. ]

Download

[(#TITRE|=={Chocolate}) Some chocolate!] would, if the test evaluates to true, display “1 Some chocolate!” (since 1 indicates a true value in PHP). But adding the |oui filter (French for yes) allows you to hide the results of the test.

Author Mark Baber Published : Updated : 19/06/10

Translations : English, français