[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



July 2010 — updated on : June 2010

All the versions of this article:

The |inserer_attribut{attribute, value} filter (since SPIP 1.8.2) is used to modify or add an HTML attribute to an HTML tag generated by the tag to which it is applied. [1]

For example:
[(#LOGO_DOCUMENT||inserer_attribut{alt, #TITRE|attribut_html})] modifies the "alt" attribute of the "img" HTML tag that is generated by the #LOGO_DOCUMENT tag by assigning it the document’s title as the value.

Il est aussi possible de vider un attribut en lui passant une valeur vide : [(#DESCRIPTIF|inserer_attribut{class, ''})]


[1The filter applies only to the first occurrence of the "attrubte" found; if there are no such occurrences found, then it is applied to the first "tag" that is found.
So [(#TEXTE|inserer_attribut{class, perso})] will modify the first "class" attribute that it finds in #TEXTE and only that one or alternatively, if there is no "class" attribute within #TEXTE at all, it will create a class="perso" for the first HTML tag that does exist within #TEXTE (by default on the opening <p>).

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