Coding with SPIP 3.0
SPIP3.0 Technical Documentation

> > > > Conditional displays

Conditional displays

The charger() or traiter() functions can indicate if the form is editable or not in their responses. This provides a means of receiving an editable parameter in the template, which can be used to hide or display the form as desired (but not the error or success messages).

It is used like this [(#ENV{editable}) ... contents of the <form> ... ]:

  1. <div class="formulaire_spip formulaire_demo">
  2.  
  3. [<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>]
  4. [<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
  5.  
  6. [(#ENV{editable})
  7. <form method='post' action='#ENV{action}'><div>
  8. #ACTION_FORMULAIRE{#ENV{action}}
  9. <ul>
  10. ...
  11. </ul>
  12. <p class='boutons'><input type='submit' class='submit' value='<:bouton_enregistrer:>' /></p>
  13. </div></form>
  14. ]
  15. </div>

Download

For any loops in the form

If there is a SPIP loop inside the code [(#ENV{editable}) ... ] (or any other tag), the SPIP compiler returns an error (or incorrectly displays the page) since this feature has not been envisaged in the current version of the template language.

To remediate this, you need to either:

  • put the loop in an include, and then call it using an <INCLURE{fond=mon/inclusion} />
  • or use the Bonux plugin and its CONDITION loop as follows:
    1. <div class="formulaire_spip formulaire_demo">
    2.  
    3. [<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>]
    4. [<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
    5.  
    6. <BOUCLE_editable(CONDITION){si #ENV{editable}}>
    7. <form method='post' action='#ENV{action}'><div>
    8. #ACTION_FORMULAIRE{#ENV{action}}
    9. <ul>
    10. ...
    11. </ul>
    12. <p class='boutons'><input type='submit' class='submit' value='<:bouton_enregistrer:>' /></p>
    13. </div></form>
    14. </BOUCLE_editable>
    15. </div>

    Download