SPIP-Contrib

SPIP-Contrib

عربي | Deutsch | English | Español | français | italiano

273 Plugins, 191 contribs sur SPIP-Zone, 31 visiteurs en ce moment

Accueil du site > Documentation > Archives documentation > FAQ > How to deactivate part of a template ?

How to deactivate part of a template ?

1er juillet 2004 – par jonathan

Toutes les versions de cet article : [français] [français]

Ceci est une ARCHIVE, peut-être périmée. Vérifiez bien les compatibilités !

Proper use of comments to debug or deactivate part of a template.

What’s the point of « commenting out » code ?

« Commenting out » to deactivate part of a template sometimes allows you to debug more effectively.

It also allows the template to be sent online when one part is not completed (this part is then « commented out »)... or just to put comments for those who will read it.

Comments in a script are important for you as well : in 6 months, you might have forgotten why you put that particular filter, while remembering that you had trouble getting the desired result.

Finally, still as a debugging tool, you can show some variables, verify their presence or their value... or simply verify that a section loop outputs the right sections : in the case of a loop that is used around an article listing loop, if your section loop doesn’t give the right results, the article loop will be wrong as well. (Of course, don’t forget to put back the comments)

As you can see, commenting out can be used for many purposes.

In Spip, it is possible to use needhave to know what you are going to comment out.

There are numerous interactions, so let me remind you that the order of execution is :

  1. Spip tags (loops, and #TEXTE...)
  2. PHP
  3. In the browser : HTML, javaScript and stylesheets.

To deactivate part of a template :

  • If it’s an HTML part, a simple HTML comment will be enough :
    <!--

    This is not interpreted by the browser (but it is by Spip)

    -->
  • For PHP : <?php # comment ?>
  • Or also
    <?php

    // echo "This line isn't interpreted by PHP";

    ?>
  • And finally :
    <php /*  

    echo "This block and what follows is not interpreted...";

    echo "(Spip instructions are still interpreted by Spip..., don't forget to close them properly, but they won't show up.)";

    echo "...until";

    */ ?>
  • You can also try and destroy loops :

Remember that commented out Spip loops will still be interpreted by Spip, which can be a problem if you use the {doublons} or {unique} filter, in that case, you will have to break the loop (voluntarily writing wrongly the word BOUCLE in this way :

<B-OUCLE_art(ARTICLES){id_article}>
#TEXTE
</B-OUCLE_art(ARTICLES){id_article}>

Of course, you also have to do it for the closing tag, which is not very practical.

For the <INCLURE(...)> it’s simpler, as you only need to do :<IN-CLURE(...)>

Let me remind you once more that in a template, the order of interpretation is :

  1. Spip
  2. PHP
  3. HTML and JavaScript and... in the browser.

P.-S.

You are welcome to help complete this article.

Retour en haut de la page

Répondre à cet article

Qui êtes-vous ?

Pour afficher votre trombine avec votre message, enregistrez-la d'abord sur gravatar.com (gratuit et indolore) et n'oubliez pas d'indiquer votre adresse e-mail ici.

Ajoutez votre commentaire ici Les choses à faire avant de poser une question (Prolégomènes aux rapports de bugs. )
Ajouter un document

Retour en haut de la page

Ça discute par ici

  • Une licence pour un article

    18 avril 2007 – 25 <blink style='color:red;'>public|spip|ecrire:commentaires</blink>

    Sur une idée originale de erational, voici un plugin permettant de lier une licence à un article.

  • Plugin Parrainage

    6 novembre 2011 – <blink style='color:red;'>public|spip|ecrire:commentaire</blink>

    Permettre aux utilisateurs d’inviter leurs contacts à s’inscrire sur le site. Description Vous connaissez le web moderne et son cortège d’applis toujours en version « beta » et de buzz sur le dernier réseau à la mode ? Vous voulez vous aussi vous y (...)

  • Formulaire de contact libre

    27 avril 2011 – 36 <blink style='color:red;'>public|spip|ecrire:commentaires</blink>

    Dans SPIP il n’y a pas un formulaire de contact, mais autant de formulaires de contact que d’auteurs. Cette phrase de Romy, dans son article Une page de contact dans mon SPIP, pointe un petit manque de SPIP. La possibilité d’insérer rapidement un (...)

  • Plugin Mot de Passe Compliqué

    2 novembre 2007 – 16 <blink style='color:red;'>public|spip|ecrire:commentaires</blink>

    Ce plugin ajoute un testeur de complexité de mot de passes dans les formulaires de choix de mot de passe de SPIP.

  • Navigation AJAX

    31 janvier – 18 <blink style='color:red;'>public|spip|ecrire:commentaires</blink>

    Ce plugin permet de modifier automatiquement une parties des liens internes de manière à ce qu’ils ne déclenchent pas un chargement complet de la page cible, mais un chargement en AJAX de certains éléments spécifiés à l’avance. Il permet aussi de (...)