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 2023-05-08 11:58:24

Mahdi Khadher
Member
Registered: 2023-04-24
Posts: 6

Adding a new button in GLPI

Hello everyone,
I'm trying to add a new button under the Management tree for the super-admin main interface that I'm gonna develop eventually. I've been digging into the files for so long and I ended up in a closed path. What I want to know is simply where to find the file responsible for rendering the home page in GLPI so I can add the button and work my way up from there.

Offline

#2 2023-05-08 12:35:21

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

Re: Adding a new button in GLPI

I would hope/recommend that you do this as a plugin and not by modifying the GLPI source code which would cause issues with updating and potentially plugins.

To start, the Plugin development documentation can be found here:
https://glpi-developer-documentation.re … index.html

There is an empty plugin provided as a starting point here:
https://github.com/pluginsGLPI/empty

Most of the existing GLPI plugins are open source, so you can refer to them for ideas too.
For adding a new menu option, it sounds like you are looking for the "menu_toadd" hook.

For my Web Resources plugin, this is the code I have in the init function of setup.php to add a new link:
$PLUGIN_HOOKS['menu_toadd']['webresources'] = [$config['menu'] ?? 'plugins' => 'PluginWebresourcesDashboard'];
For your example, you should replace the "[$config['menu'] ?? 'plugins'" part with just 'management' and "PluginWebresourcesDashboard" with the name of the PHP class that will represent this interface.


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

#3 2023-05-09 11:00:49

Mahdi Khadher
Member
Registered: 2023-04-24
Posts: 6

Re: Adding a new button in GLPI

Hi again, first I want to thank you a lot for you're reply, your message was very helpful for me and I learned a lot already. I decided to make a plugin locally for me to add my new feature and work on it. I made the files needed for the plugin to work but when I add the plugin in the plugins directory in GLPI and I go to the plugin interface I can't see my plugin being added.
For starters I wanted to add a button in the menu side bar under the Management tree that displays lets say a simple message (nothing crazy), so I made 2 files for  that being "setup.php" that contains the plugin_version function containing all information about the plugin and a function that adds the button needed via $PLUGIN_HOOKS that calls another function in the "myplugin.php" file that echo's the message.
I wanted to know what do I have to add or change in order for my plugin to show up in the plugins interface in GLPI.
Note that when I download a plugin online and I add it to GLPI it works perfectly fine.

Offline

Board footer

Powered by FluxBB