Filter syntax

Filters are applied to tags by using the pipe (“|”) character. Their effect is to call a PHP function, either one which is in the standard PHP library or one which has been declared within SPIP.

[(#TAG|filter{argument2, argument3, ...})]

Whenever a filter “x” is requested, SPIP looks for a function called “filtre_x”. If it does not find one, it looks for “filtre_x_dist”, and then “x”. It then runs the function that it has found, passing any arguments. It is important to understand that the first argument sent to the filter (and therefore to the PHP function) is the result of the component to the immediate left of that filter. Thus the example above shows the filter’s parameter list as argument2, argument3, etc.


Insert a title attribute on a link. To do this, we use the |couper filter, which allows us to cut a text down to a requested length, and the |attribut_html filter, which allows us to apply escape sequence characters to apostrophes that might cause problems with the generated HTML code (example: title='David's book' would cause a problem because of the embedded apostrophe.).

The |couper filter is applied to the result of the #TITRE tag, and the |attribut_html filter is applied to the result of the |couper filter. This shows how filters can be chained.

<a href="#URL_ARTICLE" title="[(#TITRE|couper{80}|attribut_html)]">Next article</a>

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français