Defining page tabs

Declaring the tabs for the exec pages in the private zone follows exactly the same syntax as for the buttons. The name of the parent, however, is mandatory here and corresponds to a parameter passed in the call function for the tab in the exec file:

  1. <onglet id='identifier' parent='tab bar identifier'>
  2. <icone>icon_path</icone>
  3. <titre>placeholder title</titre>
  4. <url>exec filename</url>
  5. <args>arguments</args>
  6. </onglet>

Download

As for the buttons, if the URL is not provided, then the identifier name is used as the name of the file to be loaded.

Authorisations

Again as with the buttons, an authorisation is used to manage whether the tab is displayed or not.

  1. function autoriser_identifiant_onglet_dist($faire, $type, $id, $qui, $opt) {
  2. return true; // or false
  3. }

Download

Example

The "Champs Extras 2" (Extra fields v2) plugin adds a tab into the configuration page, into the toolbar quite appropriately named "configuration". Here are the declarations used in its plugin.xml file:

  1. <pipeline>
  2. <nom>autoriser</nom>
  3. <inclure>inc/iextras_autoriser.php</inclure>
  4. </pipeline>
  5. <onglet id='iextras' parent='configuration'>
  6. <icone>images/iextras-24.png</icone>
  7. <titre>iextras:champs_extras</titre>
  8. </onglet>

Download

Authorisations are defined in the inc/iextras_autoriser.php file. The tab only displays if the author is declared as a "webmestre (webmaster)".

  1. <?php
  2. if (!defined("_ECRIRE_INC_VERSION")) return;
  3.  
  4. // function for the pipeline, nothing to do
  5. function iextras_autoriser(){}
  6.  
  7. // authorisation declarations
  8. function autoriser_iextras_onglet_dist($faire, $type, $id, $qui, $opt) {
  9. return autoriser('configurer', 'iextras', $id, $qui, $opt);
  10. }
  11.  
  12. function autoriser_iextras_configurer_dist($faire, $type, $id, $qui, $opt) {
  13. return autoriser('webmestre', $type, $id, $qui, $opt);
  14. }
  15. ?>

Download

Finally, in the exec/iextras.php file, the toolbar is called as shown below. The first is the identifier of the requested toolbar, the second is the identifier of the current tab.

  1. echo barre_onglets("configuration", "iextras");

Author Mark Baber Published : Updated : 02/06/10

Translations : English, français