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 2024-08-30 14:10:57

nmy
Member
Registered: 2014-02-18
Posts: 13

Add entry to tools menu

Hello ,

I try to add entry in tools menu but it doesn't work and I don't understand why....

here's my code:

setup.php
...
function plugin_init_mizuhocard() {
    global $PLUGIN_HOOKS;

    //required!
    $PLUGIN_HOOKS['csrf_compliant']['mizuhocard'] = true;

    //some code here, like call to Plugin::registerClass(), populating PLUGIN_HOOKS, ...
    if (Plugin::isPluginActive('mizuhocard')) {
        $PLUGIN_HOOKS['menu_toadd']['mizuhocard'] = ['Tools' => 'PluginMizuhocardMenu'];
    }
}

inc/menu.class.php
<?php

class PluginMizuhocardMenu extends CommonGLPI {

    static function getMenuName() {
        return __('Mizuho Card plugin', 'mizuhocard');
    }

    static function getMenuContent() {
       
        $URL=Plugin::getWebDir('mizuhocard').'/front/menu.php';

        $menu = [
            'title' => self::getMenuName(),
            'page'  => $URL,
            'icon'  => 'fas fa-file-import',
        ];
       
      return $menu;

    }
}

Any idea?

Offline

#2 2024-08-30 14:28:11

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,287

Re: Add entry to tools menu

$URL=Plugin::getWebDir('mizuhocard').'/front/menu.php';  should be
$URL=Plugin::getWebDir('mizuhocard').'/front/mizuhocard.php';


Trouver la panne avant de réparer...
GLPI10.0.16 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.3 reports 1.16.0 formcreator 2.13.9, datainjection 2.13.5 fields 1.21.9

Offline

#3 2024-08-30 14:34:48

nmy
Member
Registered: 2014-02-18
Posts: 13

Re: Add entry to tools menu

even if I made the above changes the result is the same, no entry in tools menu hmm

Offline

#4 2024-08-30 14:51:08

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,287

Re: Add entry to tools menu

I'm a bit confused with your plugin class name

I thought class name should be like PluginMizuhocardsMisuhocard  and then menu class like PluginMizuhocardsMizuhocardMenu  (not sure this will solve your problem)


did you also create profile thats allows you to see the plugin , otherwise plugin menu wont show until you've got right profile.


Trouver la panne avant de réparer...
GLPI10.0.16 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.3 reports 1.16.0 formcreator 2.13.9, datainjection 2.13.5 fields 1.21.9

Offline

#5 2024-08-31 12:39:19

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,809
Website

Re: Add entry to tools menu

Make sure you log out and back in or enable debug mode for your user when testing menu changes because otherwise, the menu content is cached in your login session data.


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

#6 2024-09-05 11:39:01

nmy
Member
Registered: 2014-02-18
Posts: 13

Re: Add entry to tools menu

thanks , after logout and login I see the entry tongue

Offline

#7 2024-10-05 09:03:32

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

Re: Add entry to tools menu

Good day sir, I am facing the same issue. Can you please help me?

Offline

Board footer

Powered by FluxBB