[ar] [ast] [bg] [br] [ca] [co] [cpf] [cs] [da] [de] [en] [eo] [es] [eu] [fa] [fon] [fr] [gl] [id] [it] [ja] [lb] [nl] [oc] [pl] [pt] [ro] [ru] [sk] [sv] [tr] [uk] [vi] [zh] Espace de traduction

Home > English documentation > Webmasters > Page layout: reference manual of loops and tags > Filters > |singulier_ou_plurielxxx:single_item_string, xxx:several_items_string

|singulier_ou_pluriel{xxx:single_item_string, xxx:several_items_string}

August 2010

All the versions of this article:

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 .

Show the template of this page Site powered by SPIP | Translation area | Private area