You are not logged in.
Pages: 1
Hello there.
My plugin display a new entry to tickets left menu, this use HTML and tag <style> to show the tables, buttons, labels, etc for my plugin:
<?php
include_once ("../../../../inc/includes.php");
class PluginChooseCountriesStatesCities extends CommonGLPI
{
/**
* This function is called from GLPI to allow the plugin to insert one or more item
* inside the left menu of a Itemtype.
*/
function getTabNameForItem(CommonGLPI $item, $withtemplate=0)
{
return self::createTabEntry('City Selection'); /*New Tab's Name*/
}
/**
* This function is called from GLPI to render the form when the user click
* on the menu item generated from getTabNameForItem()
*/
public static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0)
{
?>
<head>
<style>
MY STYLE
</style>
</head>
<body>
...
</body>
<?php
return true;
}
}
?>
All works perfect, the only problem is that some icons and boxes from the other default options in the main ticket page does not render correctly, this can be fix refreshing the page, but I want to add my plugin's style correctly to display it with any problem with the GLPI's style.
I think that GLPI's style and My Plugin's style are in conflict, so there are problems to render correctly items.
Thank you
Last edited by Johan Romo (2023-10-20 19:53:07)
Offline
Don't use any closing PHP tags to embed HTML directly. This isn't WordPress .
If you have styles that need loaded, feel free to put them in a CSS file in your plugin and then load that CSS in your plugin's init function using the "add_css" hook.
To display HTML content, use "echo" statements (easiest option) or, if you are in GLPI 10 or later, create a Twig template file in a "templates" folder in your plugin files and call "Glpi\Application\View\TemplateRenderer::getInstance()->render()" with the relative path. It would be "@" + the plugin folder name + path relative to the templates folder. You do not include "templates" in the path.
The majority of GLPI plugins are open source, so they can be used as a reference point. There is also an example plugin which could be a good start as a reference, if not completely functional.
https://plugins.glpi-project.org/#/
https://github.com/pluginsGLPI/example
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
Thank you
Offline
Pages: 1