SPIP

[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] [vi] [zh] Espace de traduction

Download

|couper

July 2010 — updated on : June 2010

All the versions of this article:


The |couper filter truncates a text after a certtain configurable number of characters. It attempts not to cut any words in half and removes any formatting from the text. If the original test is long than the truncated portion, then "(...)" will be added to the end of the extract to indicate that there is a continuation of the text.
The filter truncates by default at 50 characters, but you can specify any other length you wish by passing it as a parameter to the filter: e.g. [(#TEXTE|couper{80})].

In addition, this filter cleans the text from any HTML tags (or other formatting) that the text contains: no more links, no bold or italics, no code, no frames etc. We are left with simply just raw text.

Since spip2, it has been possible to customise the ellipses that are added afterwards with the following second parameter options:
[(#TEXTE|couper{80, '...'})]
[(#TEXTE|couper{80, '&nbsp;<img src="truc.png" alt="">'})]

Note also that it is often the case that the truncation does not occur exactly at the requested number of characters (since words are not truncated in the middle).


See also the #INTRODUCTION tag.


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