You are not logged in.
I am learning to develop GLPI plugins by following this tutorial: https://www.neteye-blog.com/2016/12/how … pi-plugin/
The tutorial explains how to add it to the "Computer" tab, but I want to add it to the "Tools" menu. Neither of these works for me.
How do I add the plugin to the menu?
This is the code I have so far:
setup.php
<?php
define('XMLTEU_VERSION', '1.0.1');
function plugin_init_xmlteu() {
global $PLUGIN_HOOKS;
$PLUGIN_HOOKS['csrf_compliant']['xmlteu'] = true;
Plugin::registerClass('PluginXmlTeuXml', array('addtabon' => array('Computer')));
}
if (!defined("PLUGIN_XMLTEU_DIR")) {
define("PLUGIN_XMLTEU_DIR", GLPI_ROOT . "/plugins/xmlteu");
}
function plugin_version_xmlteu() {
return array(
'name' => "XML TEU",
'version' => '1.0.0',
'author' => 'Alejandro Cuesta && Andrés Rocher && Josep Garzó',
'license' => 'GPLv2+',
'homepage' => '',
'minGlpiVersion' => '0.85'
);
}
function plugin_xmlteu_check_config() {
return true;
}
function plugin_xmlteu_check_prerequisites() {
return true;
}
hook.php
<?php
function plugin_xmlteu_install() { return true; }
function plugin_xmlteu_uninstall() { return true; }
xmlteu.class.php
<?php
class PluginXmlTeuXml extends CommonGLPI
{
function getTabNameForItem(CommonGLPI $item, $withtemplate=0)
{
return self::createTabEntry('XML TEU');
}
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0)
{
?>
<h1>aaa</h1>
<?php
return true;
}
}
Offline
Inside Setup.php:
Plugin::registerClass('PluginXmlTeuXml', array('addtabon' => array('Computer', 'Tools')));
$PLUGIN_HOOKS["menu_toadd"]['PluginXmlTeuXml'] = ['tools' => 'PluginXmlTeuXmlMenu'];
$PLUGIN_HOOKS['config_page']['PluginXmlTeuXml'] = 'front/index.php';
$PLUGIN_HOOKS['menu']['PluginXmlTeuXml']= true;
Offline
Is the issue resloved?
Offline