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 forms according to the configuration set 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.

[SPIP 1.8.2] 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{'thanks.php3'})] takes the visitor to the page merci.php3.
  • [(#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

[SPIP 1.4] 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

[SPIP 1.4] 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.

-  #LOGIN_PRIVE

[SPIP 1.4] 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_login.php3, i.e. by the default login-dist.html template. On direct access to the /ecrire URL Spip will redirect you to spip_login.php3.

-  #LOGIN_PUBLIC

[SPIP 1.4] 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 — this, however, remains rather an intricate process, and will require to be developed further before the tag can be easy to use for all. Nevertheless, an example of advanced use of this tag is offered below.

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:

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 [SPIP 1.5] is the counterpart of #LOGIN_PUBLIC; it returns a URL enabling a logged-in visitor to log out.

Here’s a simple, but thorough example of how to use both tags. A little PHP is necessary to test the {{$auteur_session}} variable which shows if an author is logged in or not. If she is, her status, login, etc. can be returned, and even tested through $auteur_session['statut']....

Note that the content is made secure on this template only. If your template "Print this article", for instance, doesn’t check $auteur_session, anyone, search engines included, will be able to have access to the very same content you wish to protect.

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 : 26/10/12

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