Using the private space CVT forms on public-facing pages

  • New in : SPIP 2.0

For CVT forms employed in SPIP’s private space can also be used in public-facing templates [1]. These forms allow you to create or modify site elements such as articles, sections, etc.

These forms are constructed based on the files made available in the prive/formulaires/ directory, where, for each of the forms, there are a pair of files of the type: editer_article.html ; editer_article.php.

For further information on how these tags work, please reader the article The CVT forms of SPIP.

1 - FORMULAIRE_EDITER_ARTICLE

#FORMULAIRE_EDITER_ARTICLE{id_article, id_rubrique, retour, lier_trad}

Parameters of the tag:

  • id_article specifies the identifier of the article to be modified. If it equals "oui" (yes), then the form will create a new article.
  • id_rubrique specifies the identifier of the section containing the article to be edited.
  • retour is used to define the URL to which the user will be redirected once the form has been validated.
  • lier_trad is used to indicate that the article created is a translation of the article passed in the context.

2 - FORMULAIRE_EDITER_RUBRIQUE

#FORMULAIRE_EDITER_RUBRIQUE{id_rubrique, id_parent, retour, lier_trad}

Parameters of the tag:

  • id_rubrique determines the identifier of the section to be modified. If set to "yes", the form will create a new section.
  • id_parent determines the identifier of the section containing the section to be edited.
  • retour is used to define the URL to which the user will be redirected once the form has been validated.
  • lier_trad is used to indicate that the section created is a translation of the section passed in the context.

For example, to create a section from a section page :

[(#FORMULAIRE_EDITER_RUBRIQUE{oui, #ID_RUBRIQUE, [(#SELF|parametre_url{id_rubrique, #ID_RUBRIQUE})]})]

3 - FORMULAIRE_EDITER_AUTEUR

#FORMULAIRE_EDITER_AUTEUR{id_auteur, retour, lier_id_article}

Parameters of the tag:

  • id_auteur specifies the identifier of the author to be modified. If it equals "oui" (yes), then the form will create a new author.
  • retour is used to define the URL to which the user will be redirected once the form has been validated.
  • lier_id_article is used to attach the author to an article when it is created.

4 - FORMULAIRE_EDITER_GROUPE_MOT

#FORMULAIRE_EDITER_GROUPE_MOT{id_groupe, retour}

Parameters of the tag:

  • id_groupe specifies the identifier of the keywords group to be modified. If it equals "oui" (yes), then the form will create a new group.
  • retour is used to define the URL to which the user will be redirected once the form has been validated.

5 - FORMULAIRE_EDITER_MOT

#FORMULAIRE_EDITER_MOT{id_mot, id_groupe, retour,  ajouter_id_article, table, table_id}

Parameters of the tag:

  • id_mot specifies the identifier of the keyword to be modified. If it equals "oui" (yes), then the form will create a new keyword.
  • id_groupe specifies the identifier of the group that contains the keyword to be edited.
  • retour is used to define the URL to which the user will be redirected once the form has been validated.
  • ajouter_id_article is used to attach the keyword to an object when it is created.
  • table is used to specify the type of object to which the keyword is linked when it is created (e.g. "articles" for an article).
  • table_id is used to specify the name of the field representing the id of the object to which the keyword is linked when it is created (e.e. "id_article" for an article).

6 - FORMULAIRE_EDITER_SITE

#FORMULAIRE_EDITER_SITE{id_syndic, id_rubrique, retour, lier_trad}

Parameters of the tag:

  • id_syndic specifies the identifier of the site to be modified. If it equals "oui" (yes), then the form will create a new site.
  • id_rubrique specifies the identifier of the section containing the site to be edited.
  • retour is used to define the URL to which the user will be redirected once the form has been validated.
  • lier_trad is used to indicate that the section created is a translation of the site passed in the context.

7 - FORMULAIRE_EDITER_BREVE

#FORMULAIRE_EDITER_BREVE{id_breve, id_rubrique, retour, lier_trad}

Parameters of the tag:

  • id_breve determines the identifier of the brief to be modified. If set to "yes", the form will create a new news item.
  • id_rubrique determines the identifier of the section containing the brief to be edited.
  • retour defines the URL to which the user will be redirected once the form has been validated.
  • lier_trad is used to indicate that the news item created is a translation of the one passed in the context.

8 - Restricting the display of the forms

If the actions called during the processing of the form are secured using mechanisms internal to SPIP, it is important to note that these forms are accessible to everyone as soon as you insert them into a public-facing template.

To restrict the display of a form in a template, you can either use the #AUTORISER or #SESSION tags.

For example, to display an article creation form only to site administrators, you could use:

[(#SESSION{statut}|=={0minirezo}|oui)
	#FORMULAIRE_EDITER_ARTICLE{oui, #ID_RUBRIQUE}
]

 

9 - Customisation

There are two ways of customising a form:

Surcharge you need to create a copy of the files...

  • editer_xxx.html
  • editer_xxx.php

...in a directory /squelettes/formulaires/ and make the desired changes.

Caution: forms overloaded in this way will now be used in the private area where they will replace the originals.

Pipeline : a pipeline allows you to modify the content of the edit_xxx.html file or the default result of the functions contained in edit_xxx.php for any CVT form.

This is the preferred method for plug-ins.

The test_space_prive() function, which indicates whether or not you are in private space, can also be useful.

10 - See also

If you want to customise an existing form, you will find the following three articles very useful, particularly the section on "Special fields".

On Programmer.spip.net

then on a case-by-case basis...

Footnotes

[1It is therefore possible to "overload" these forms by modifying a copy that is to be carefully stored in a directory named squelettes/formulaires/
Warning: any such forms that are modified/overloaded will from now on be used in the private space too where they will replace the SPIP originals.

Author Mark Published : Updated : 14/07/23

Translations : English, français, Nederlands