|lien_ou_expose

The |lien_ou_expose filter returns either a clickable link or just a simple text title.

  • New in : SPIP 2.1

When applied to a given URL, the |lien_ou_expose{text_title, condition} displays according to the result of the condition either the clickable link to this url if the condition is not verified, or only the title passed as an argument if the condition is verified.

Example:

[(#URL_RUBRIQUE|lien_ou_expose{#TITRE, #ENV{test}|=={en_cours}})]


will display if there is a variable named "test" and its value is "en_cours" (in progress) in the current environment:

<strong class='on'>Title_of_the_section</strong>
otherwise it will instead display just:
<a href="spip.php?rubriquexx">Title_of_the_section</a>

The filter also accepts 3 optional supplementary arguments "class", "title" and "rel".

[(#URL_RUBRIQUE|lien_ou_expose{#TITRE, #ENV{test}|=={en_cours}, spip_link, the best section, libraryentry})]

producing either the following HTML source (depending on the condition):
<strong class='on'>Title_of_the_section</strong>
otherwise it generates just:
<a href='-Title_of_the_section-.html' class='spip_link' title='the best section' rel='libraryentry'>Title_of_the_section</a>

As of SPIP 4.0 the 2nd argument of the SPIP filter (3rd argument of the PHP function) can be a simplified CSS selector of type a.active or strong.active.expose to specify the tag (a, span or strong only) and the class(es) to use when exposed.

Example :

 [(#URL_RUBRIQUE|lien_ou_expose{#TITRE, #ENV{test}|=={en_cours}|?{a.mylink.active}, 'mylink'})]

See also

Author Mark Published : Updated : 20/04/23

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