The |singulier_ou_pluriel
filter is usually applied to assign (singular or plural) character strings depending on the return value of a tag.
Example:
Let’s say that we have the following declarations in our local_xx.php language file:
'quantity_something_one' => 'there was 1 result returned by this loop.',
'quantity_something_more' => 'there were @nb@ results returned in this loop.'
And then we code a SPIP loop as below:
<BOUCLE_a(ARTICLES) {criteria...}>
...
</BOUCLE_a>
[(#TOTAL_BOUCLE|singulier_ou_pluriel{local:quantity_something_one, local:quantity_something_more, nb})]
</B_a>
- If the loop only returns a single entry, then it will display:
there was 1 result returned by this loop.
- If the loop returns 36 entries, then it will display:
'there were 36 results returned in this loop.
Note that we can pass a 3rd argument to this filter: nb
, which allows us to include the actual numerical value returned by the tag inside the character string.
Attention:
This filter explicitly expects some language idioms as its arguments. You should therefore not pass it any language tags:|singulier_ou_pluriel{module:one_item, module:more_items}
is the correct syntax;|singulier_ou_pluriel{<:module:one_item:>, <:module:more_items:>}
is the incorrect syntax .