Coding with SPIP 2.1
SPIP 2.1 Technical Documentation

> > > > ajouter_onglets

ajouter_onglets

This pipeline is used to add tabs to the exec pages in the private zone. It is not so nearly useful since the creation of the <onglet> tag in the plugin.xml file (see Defining page tabs).

  1. return pipeline('ajouter_onglets', array('data'=>$onglets,'args'=>$script));

The "ajouter_onglets" pipeline accepts a table of couples of "tab identifier / tab description" (PHP class of Bouton), but also an identifier for the tab toolbar (in args).

  1. // add a tab to SPIP's configuration page
  2. function plugin_ajouter_onglets($flux){
  3. if ($flux['args']=='identifiant')
  4. $flux['data']['identifiant_bouton']= new Bouton("mon/image.png", "titre de l'onglet"), 'url');
  5. return $flux;
  6. }

Download

The third url parameter for the Bouton class is optional. By default it will be an "exec" page with the same name as the provided identifier (ecrire/?exec=identifier).

In the exec pages, a toolbar is called with two arguments: the identifier of the desired toolbar and the identifier of the active tab:

  1. echo barre_onglets("tab toolbar identifier", "active tab identifier");
  2. echo barre_onglets("configuration", "contents");

Download

Example

The "Agenda" plugin modifies the default tabs for SPIP’s calendar by using this pipeline:

  1. function agenda_ajouter_onglets($flux) {
  2. if($flux['args']=='calendrier'){
  3. $flux['data']['agenda']= new Bouton(
  4. _DIR_PLUGIN_AGENDA . '/img_pack/agenda-24.png',
  5. _T('agenda:agenda'),
  6. generer_url_ecrire("calendrier","type=semaine"));
  7. $flux['data']['calendrier'] = new Bouton(
  8. 'cal-rv.png',
  9. _T('agenda:activite_editoriale'),
  10. generer_url_ecrire("calendrier", "mode=editorial&type=semaine"));
  11. }
  12. return $flux;
  13. }

Download

Migration to the new system
To rewrite this example in the new system, 2 things need to be separated: the declaration of the button, and the authorisation to see it or not. The declaration is made in the plugin.xml file:

  1. <onglet id="agenda" parent="calendrier">
  2. <icone>img_pack/agenda-24.png</icone>
  3. <titre>agenda:agenda</titre>
  4. <url>calendrier</url>
  5. <args>type=semaine</args>
  6. </onglet>
  7. <onglet id="calendrier" parent="calendrier">
  8. <icone>cal-rv.png</icone>
  9. <titre>agenda:activite_editoriale</titre>
  10. <url>calendrier</url>
  11. <args>mode=editorial&type=semaine</args>
  12. </onglet>

Download

The authorisation is relocated into a special function (use the autoriser pipeline to define it):

  1. function autoriser_calendrier_onglet_dist($faire, $type, $id, $qui, $opt) {
  2. return true;
  3. }
  4. function autoriser_agenda_onglet_dist($faire, $type, $id, $qui, $opt) {
  5. return true;
  6. }

Download

  • Author :
  • Published :
  • Updated : 31/05/10
  • Translations : English, français