You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2021-04-06 12:39:50

arielmanra
Member
Registered: 2019-03-26
Posts: 40

Add plugin to the "Tools" menu

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

#2 2021-04-20 15:45:30

Kaya84
Member
Registered: 2019-06-13
Posts: 217

Re: Add plugin to the "Tools" menu

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

#3 2024-10-05 08:57:36

vishnu gopal
Member
Registered: 2024-09-27
Posts: 15

Re: Add plugin to the "Tools" menu

Is the issue resloved?

Offline

Board footer

Powered by FluxBB