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:

<onglet id='identifier' parent='tab bar identifier'>
	<icone>icon_path</icone>
	<titre>placeholder title</titre>
	<url>exec filename</url>
	<args>arguments</args>
</onglet>

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.

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

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:

<pipeline>
	<nom>autoriser</nom>
	<inclure>inc/iextras_autoriser.php</inclure>
</pipeline>	
<onglet id='iextras' parent='configuration'>
	<icone>images/iextras-24.png</icone>
	<titre>iextras:champs_extras</titre>
</onglet>

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

<?php
if (!defined("_ECRIRE_INC_VERSION")) return;

// function for the pipeline, nothing to do
function iextras_autoriser(){}

// authorisation declarations
function autoriser_iextras_onglet_dist($faire, $type, $id, $qui, $opt) {
	return autoriser('configurer', 'iextras', $id, $qui, $opt);
}

function autoriser_iextras_configurer_dist($faire, $type, $id, $qui, $opt) {
	return autoriser('webmestre', $type, $id, $qui, $opt);
}
?>

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.

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

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français