Forms

SPIP allows a good deal of interactivity with the site’s visitors. To this end, SPIP provides many forms on the public site, some manage the access to the private area, others allow the participation to a forum or the signing of a petition.

A form is added to a template with a simple tag; SPIP then manages the (often complex) behaviour of these forms according to the environment and the configurations made in the private area.

Interactive Functions

-  #FORMULAIRE_RECHERCHE

This displays the interface for SPIP’s integrated search engine. It is documented in the article called The Search Loops.

-  #FORMULAIRE_FORUM

This displays an interface allowing messages to be posted in the public forums. It is usually used in a FORUMS loop, but can also be placed in any loop which accepts a forum:

The form depends of course on the configuration of moderation for the forum, i.e. immediate publication (afterwards moderation), beforehand moderation or compulsory registration.

By default, once a message has been posted, the visitor is taken to the page of the element [1] to which he or she has replied. It is possible to send the visitor to another page instead by adding a URL as a parameter to the tag. For example:

  • [(#FORMULAIRE_FORUM{'spip.php?page=thanks'})] takes the visitor to the page spip?page=thanks.
  • [(#FORMULAIRE_FORUM{#SELF})] takes the visitor to the page containing the form of the forum (see the #SELF tag).

In the very specific case where the use of keywords in public forums is permitted, you can refine the behaviour of this form with the Variables for customizing SPIP.

-  #FORMULAIRE_SIGNATURE

The form inserted by #FORMULAIRE_SIGNATURE allows for the signing of a petition associated with an article (so this form is placed inside an ARTICLES loop).

N.B. Signing a petition requires the validation of the signatories by email, it is dependent upon your host provider allowing email to be sent with PHP.

-  #FORMULAIRE_SITE

The #FORMULAIRE_SITE tag displays a form which allows visitors to suggest a referencing of another website. These proposals appear in the private area for validation by an administrator.

The form is only displayed if you have enabled the "Manage Web sites directory" option and set "Who can propose referenced sites?" to "Visitors of the public site" in the "Site Configuration" page of the private area ("The Site’s Content").

Because SPIP only allows referenced sites to be attached to sections, the #FORMULAIRE_SITE tag can only be used within a RUBRIQUES loop.

-  #FORMULAIRE_ECRIRE_AUTEUR

When placed in an AUTEURS loop this tag displays a form which allows a message to be sent to the author of an article. This allows visitors to write to the author without the author’s email address being visible on the public site. (By default, author links in the templates do contain the author’s email address).

Registration, logging in and out

-  #FORMULAIRE_INSCRIPTION

This is one of the most important form tags as it manages the registration of new editors. The form will only be displayed if you’ve enabled automatic registration from the public site — otherwise, nothing at all will be displayed.

As registration requires login information (login and password) to be sent by email this tag is dependent upon your host allowing email to be sent with PHP.

-  #FORMULAIRE_LOGIN

Since SPIP 3.0, this tag generalizes and replaces the #LOGIN_PRIVE and #LOGIN_PUBLIC. It can receive 3 arguments

  • the destination URL after identification. Specific case: the value @page_auteur allows to be redirected after connection on the public template of the author who connects.
  • the login of the person to be identified, if it is known.
  • a value which indicates if the login leads to the private space (if it is not empty) or public (if it is an empty string).

For example, in the template distributed with spip, the login.html file contains the following call:

[(#FORMULAIRE_LOGIN{#ENV{url}|sinon{#URL_ECRIRE{accueil}}})]

Since SPIP 4.0, this tag can receive its parameters in a new form:
-  the destination URL
-  an associative array of options whose values can be :

  • login
  • prive
  • autofocus: when this value is false (an empty string), there will be no autofocus on the login field (otherwise, it receives focus automatically).

In this theoretical example, the login redirects to the ’target’ page of the private, the proposed identifier is ’toto’ and there is no autofocus:
#FORMULAIRE_LOGIN{cible,#ARRAY{login,toto,prive,1,autofocus,""}}

-  #LOGIN_PRIVE (deleted in SPIP 4.0)
This tag is deprecated: use #FORMULAIRE_LOGIN instead.

Just as important, the #LOGIN_PRIVE displays the form which gives you access to the private area, i.e. to the "/ecrire/" part of the site.

Important: this tag must necessarily be included in the template called by the spip.php?page=login, i.e. by the default login-dist.html template. On direct access to the /ecrire URL Spip will redirect you to spip.php?page=login.

-  #LOGIN_PUBLIC (deleted in SPIP 4.0)
This tag is deprecated: use #FORMULAIRE_LOGIN instead.

The #LOGIN_PUBLIC tag has a more specific function. It displays a form allowing your visitors to log in while on the public site without having to enter the private area. This tag can be used mainly to log in visitors on forum-providing sites. It can also be used as a basic means of restricting access to certain pages on the public site.

By default, the #LOGIN_PUBLIC "loops upon itself", i.e. the form returns to the page where it is, though you can define a page the form will lead to in this way:

 [(#LOGIN_PUBLIC{#URL_PAGE{mypage}})]

If your site allows automatic registration to the private area, login data for the public site will be the same as those for the private area. In other words, the login sent to a user for entering the public site will also give them access to the private area. If, on the contrary, you do not allow automatic registration to the private area, you need to have at least one article whose forums are set to “on registration” to be able to use this tag. Only then will SPIP be able to provide login information for the public site without access to the private area.

-  #URL_LOGOUT
It is the counterpart of #LOGIN_PUBLIC; it returns a URL enabling a logged-in visitor to log out.
Note that #URL_LOGOUTbeing a dynamic tag, it will always return something so that the conditional parts (SPIP’s tags: the syntax) of the tag will always be displayed. Thus a notation of the type [<a href="(#URL_LOGOUT)">disconnecting</a>] will return the html source <a href="">disconnecting</a> when the visitor is not logged in. For a conditional display of the logout link, see below.

A parameter can be passed to this tag to specify the return address after the disconnection.
For example

[(#URL_LOGOUT{#URL_PAGE{sommaire}})]

will return to the home page.

Complete example to manage connection / disconnection

[(#SESSION{id_auteur}|non) #LOGIN_PUBLIC]
[(#SESSION{id_auteur}|oui)<a href="#URL_LOGOUT">disconnection</a>]

Style sheets

You can change the graphic interface of forms a good deal through editing style sheets, namely the following class selectors: forml, spip_encadrer and spip_bouton — for more information, see the section Changing the layout and graphics and Spip and Style Sheets.

Footnotes

[1article, section, news item, site or forum

Author bealach, Paul Knight Published : Updated : 20/04/23

Translations : عربي, català, Deutsch, English, Español, français, italiano, Nederlands