|singulier_ou_pluriel{xxx:single_item_string, xxx:several_items_string}

The |singulier_ou_pluriel filter is used to vary an output display depending on the numeric value returned by the tag to which it is applied.

The |singulier_ou_pluriel filter is usually applied to assign (singular or plural) character strings depending on the return value of a tag.


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...}>
[(#TOTAL_BOUCLE|singulier_ou_pluriel{local:quantity_something_one, local:quantity_something_more, nb})]

-  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.

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 .

Author Mark Published : Updated : 26/10/12

Translations : català, English, français, Nederlands