Highlighting an item in a list

The #EXPOSE{arg1,arg2} tag is used to highlight, either in a menu or in a list, the main object of the page which the site visitor is currently viewing.

The object which is being "exposed" is the article (or news item, or section, or keyword, or author) which belongs to the current "context". In the case of sections, the breadcrumb hierarchy is generated, which makes it possible to "expose" the hierarchy of the sections that contain the article (or other object) being displayed.

By default, SPIP replaces the #EXPOSE tag with "on" if the object matches that of the context; otherwise the tag returns nothing at all.

However, the #EXPOSE tag can accept either one or two arguments, which allow you to specify what should be displayed for the exposed object, and what should be displayed for all the other objects. As an example, writing [(#EXPOSE{yes,no})] will display "yes" for the exposed object, and "no" for all of the others.

Displaying the exposed article differently

In its simple form, the #EXPOSE tag allows you to change the appearance of the link to the current article differently from other articles in a navigation menu. To modify the style of the links in such a menu, we could insert the #EXPOSE tag in the following manner into the article.html template:

<BOUCLE_mainloop (ARTICLES) {id_article}>
	<B_menu>
	<ul>
		<BOUCLE_menu (ARTICLES) {id_rubrique}>
		<li>
		<a href="#URL_ARTICLE"[ class="(#EXPOSE)"]>
		#TITRE
		<a>
		</li>
		</BOUCLE_menu>
	</ul>
	</B_menu>
	#TEXTE
</BOUCLE_mainloop>

with the following style instructions:

a { color: blue; }
a.on { color: red; font-weight: bold; }

The object which is exposed in the list will then be highlighted by using different style commands

With a small change to the code, it is also possible to disable the link on the highlighted article as well as changing its appearance:

<B_menu>
<ul>
	<BOUCLE_menu(ARTICLES){id_rubrique}>
	<li>
		<#EXPOSE{span,a href="#URL_ARTICLE"}[ class="(#EXPOSE)"]>
		#TITRE
		</#EXPOSE{span,a}>
	</li>
	</BOUCLE_menu>
</ul>
</B_menu>

which will generate the following HTML code, where the <a> tags are replaced with <span> codes instead:

<ul>
<li><a href="article1.html">All about my sister</a></li>
<li><span class="on">All about me</span></li>
<li><a href="article3.html">All about my brother</a></li>
</ul>

which will be displayed like this:

See also

Author bealach, Mark, Paolo Published : Updated : 05/04/23

Translations : عربي, català, Deutsch, English, Español, français, italiano, Nederlands, òc lengadocian, Türkçe