#TAG* and #TAG**

By default, SPIP automatically applies all the treatments (filters or transformation functions) specific to each #TAG encountered in the templates, treatments defined in the #$GLOBALS['table_des_traitements']['TAG_NAME'].

  • New in : SPIP 1.9

In certain scenarios, e.g. to execute a customised filter before the automatic application of SPIP’s internal functions, it is necessary to deactivate these automatically applied processes.

The single asterisk: *

In such scenarios, we apply the syntax #TAG*, to which the SPIP programmer can then apply the customised filter, whilst paying attention to carefully check if it is necessary to reapply those normally standard internal processes which have just been deactivated after the custom filter.

For example:

[(#TEXTE*|my_filter|propre)]

will start by deactivating the automatic processes applied to #TEXTE and defined in #$GLOBALS['table_des_traitements']['TEXTE'] ;
then it will apply the custom filter |my_filter ;
and finally it will apply the |propre filter which was previously deactivated using the * single asterisk.

Illustration:
The text of my article, such as I entered it using the back-end interface and as is stored in the database is [1] :

<img388|left>

{Three hundred and forty-eight years, six months, and nineteen days} ago to-day, the Parisians awoke to the sound of all the bells in the triple circuit of the city, the university, and the town ringing a full peal.
The {{sixth of January, 1482}}, is not, however, a day of which history has preserved the memory.

#TEXTE displays the following HTML source (with the default processes having been applied):

<p><span class="spip_document_388 spip_documents spip_documents_left" style="float: left; width: 150px;">
<img src="../local/cache-vignettes/L150xH150/extraits-4f9ff.jpg" alt="" style="height: 150px; width: 150px;" height="150" width="150"></span></p>
<p><i>Three hundred and forty-eight years, six months, and nineteen days</i> ago to-day, the Parisians awoke to the sound of all the bells in the triple circuit of the city, the university, and the town ringing a full peal.
<br>The <strong>sixth of January, 1482</strong>, is not, however, a day of which history has preserved the memory.</p>

#TEXTE* will, however, display this HTML source instead:

<img388|left>


{Three hundred and forty-eight years, six months, and nineteen days} ago to-day, the Parisians awoke to the sound of all the bells in the triple circuit of the city, the university, and the town ringing a full peal.
The {{sixth of January, 1482}}, is not, however, a day of which history has preserved the memory.

To this raw source, we will apply a custom filter (the filter will modify the image associated with this article, and do so only within this specific template file, which is not an option available to us by simply re-editing the article itself...). This filter, therefore, searches for the text string <imgxxx| and replaces it with <img25|; in other words: it replaces the images linked to the article with a standard single image. Note that this exercise would not be possible (at least, not easily) by working with the HTML source returned by using the ordinary #TEXTE.

Once our special filter has done its work, we must re-apply the automatic processes that SPIP would apply to the #TEXTE tag to generate the template process <img25|left> and to apply the standard typographical processes that might be necessary: bolding, italics, section headings, etc.

So we therefore instruct our template as follows:

[(#TEXTE*|my_filter|propre)]

, which will generate our new HTML source:

<p><span class='spip_document_25 spip_documents spip_documents_left'  style='float:left; width:180px;'>
<img src='IMG/png/defaut_cache.png' width="180" height="180" alt="" /></span></p>
<p>Three hundred and forty-eight years, six months...

The double asterisk: **

In addition to what we have just discussed above, SPIP by default applies to all tags encountered in a template file a security process which interrupts the execution of (PHP or JavaScript) scripts that might be returned by the database for particular fields. For example, including <?php echo 'yum-yum'; ?> within the body of an article’s text will not result with that PHP code being executed (and "yum-yum" will not be output to the resulting HTML file).

In some very specific and rare scenarios, though, it may be necessary to retrieve the original raw data that has not been cleaned (and therefore potentially dangerous) for a given tag. For example, this can be the case for processing certain form data where environmental variables are passed using #ENV.

In these cases, and being aware of the risks involved, the notation #TAG** should be used. But once again, be careful with this writing (see the use of the #ENV tag in this regard).

Footnotes

[1thanks to Victor Hugo for this extract from The Hunchback of Notre Dame - Translated by Isabel F. Hapgood (1888).

Portfolio

Author Mark Published : Updated : 19/07/23

Translations : català, English, Español, français, Nederlands, Português