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 2025-02-03 11:03:34

DeveloperLabs
Member
Registered: 2025-01-30
Posts: 4

Path in dropdowns

Hello,

I have this code in my file /plugins/licensemanager/front/licensecontract.php:

<?php

use GlpiPlugin\Licensemanager\LicenseContract;

include ("../../../inc/includes.php");

Html::header(__('License Contracts', 'licensemanager'), $_SERVER['PHP_SELF'], 'management', 'glpiplugin\licensemanager\menu');
Search::show(LicenseContract::class);
Html::footer();

If I click on the created menu entry 'License Contracts' it shows the view and the correct path at the top ("Home" -> "Management" -> "License Contracts").

Now I have added a dropdown to the config section which is displayed on an own accordion/tab named by the name of the plugin. For better structure I moved the entries for dropdowns in a subfolder of src: src/Dropdowns.

In the file /plugins/licensemanager/front/dropdowns/status.php I added the path similar to the other menu:

<?php

use GlpiPlugin\Licensemanager\Dropdowns\Status;

include ("../../../../inc/includes.php");

Html::header(__('License & Contracts Mgmt', 'licensemanager'), $_SERVER['PHP_SELF'], 'config', 'commondropdown', 'glpiplugin\licensemanager\dropdowns\status');
Search::show(Status::class);
Html::footer();

But at the top it only shows "Home" -> "Setup" -> "Dropdowns" without "Status".

This is the content of the status class:

<?php
namespace GlpiPlugin\Licensemanager\Dropdowns;

use \CommonDropdown;

class Status extends CommonDropdown {

    public static $table = 'glpi_plugin_licensemanager_dropdowns_statuses';

    public static function getTypeName($nb = 0) {
        return __('Status', 'licensemanager');
    }

    public static function getTable($classname = null): string {
        return self::$table;
    }

   public static function canView(): bool {
       return true;
   }

}

The table exists and has 1 entry.

What is missing/wrong here?

Last edited by DeveloperLabs (2025-02-03 11:05:23)

Offline

#2 2025-02-18 14:03:13

DeveloperLabs
Member
Registered: 2025-01-30
Posts: 4

Re: Path in dropdowns

Change

<?php

use GlpiPlugin\Licensemanager\Dropdowns\Status;

include ("../../../../inc/includes.php");

Html::header(__('License & Contracts Mgmt', 'licensemanager'), $_SERVER['PHP_SELF'], 'config', 'commondropdown', 'glpiplugin\licensemanager\dropdowns\status');
Search::show(Status::class);
Html::footer();

to

<?php

 // Include the necessary class
 use GlpiPlugin\Licensemanager\Dropdowns\Status;
 
 // Include the core GLPI initialization file
 require_once __DIR__ . "/../../../../inc/includes.php";
 
 // Create a new instance of the Status class.
 // This object is used to manage status entries within the GLPI plugin.
 // It allows retrieving, displaying, and handling status-related data.
 $dropdown = new Status();
 
 // Include the GLPI common dropdown handler.
 // This script is responsible for rendering and processing dropdown elements, 
 // ensuring proper integration within GLPI’s UI. It also handles form submissions, 
 // permissions, and data validation.
 require_once GLPI_ROOT . "/front/dropdown.common.php";

Offline

Board footer

Powered by FluxBB