SPIP

[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

Download

#TAG* and #TAG**

June 2010 — updated on : October 2012

All the versions of this article:

By default, SPIP automatically applies some standard processes (filters and conversion functions) on every #TAG found inside the SPIP template files, processes which are specific to each of those tags and which are defined in the #$GLOBALS['table_des_traitements']['TAG_NAME'].


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 scenarios, and in full knowledge of the associated risks, we can use the #TAG** notation. But let us repeat the point here, be very careful using this technique (compare with how the #ENV tag can be used).

 
 
 
 

Footnotes

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


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