Table of contents
{xxxx IN a,b,c,d}
available from SPIP 1.8, 1.8.1 onwards, restricts the display of results that have the xxxx criterai equal to a, b, c or d.
The results are sorted in the order indicated (unless explicitly requested to sort them using another sort criteria). It is also possible to select based on character strings, e.g. {titre IN 'China', 'Japan'}
It is similarly possible to pass an array as an argument (from SPIP 1.9 onwards).
This can be an array defined by an #ARRAY tag or perhaps an array originating from a #ENV**{my_post}
tag.
If #ENV{my_post}
is an array (originating perhaps from form entries where the name attribute ends in []
), and if the analysis filters have been deactivated by adding a double asterisk to this tag, then each element of the array will be considered as an argument for IN, SPIP applying the security filters to each of them in turn [1].
The standard formulaire_forum_previsu template file offers an example of using this criteria within a MOTS (keywords) loop, using the criteria {id_mot IN #ENV**{ajouter_mot}}
:
this loop only selects the keywords belonging to a collection that is determined dynamically. In this case, the collection will have been constructed by the standard template file called "choix_mots" (select_words), which uses the name=ajouter_mot[]
attribute.
Conditional usage of the IN operator within a loop’s criteria
Usage example:
- If #ID_ARTICLE exists in the environment and has a value:
<BOUCLE_a(ARTICLES) {id_article ?IN 11,12,13}>
will only display articles with an ID that is included in the IN list
<BOUCLE_a(ARTICLES) {id_article ?!IN 11,12,13}>
will only display articles with an ID that is NOT included in the IN list [2]
- If #ID_ARTICLE does not exist in the environment:
<BOUCLE_a(ARTICLES) {id_article ?IN 11,12,13}>
will display ALL articles including those with an ID in the IN list
<BOUCLE_a(ARTICLES) {id_article ?!IN 11,12,13}>
will also display ALL articles including those with an ID in the IN list [2]