You are not logged in.
Pages: 1
Topic closed
hi, im from spain so sorry for my english, i have a problem when developing a new plugin for glpi:
i have a class into glpi/plugins/monitorizacion/inc/plugin_monitorizacion.class.php and it has this code:
class plugin_monitorizacion{
static function printtree{
/*and its code*/
}
}
and a php that calls that class like this:
plugin_monitorizacion::printtree
but the problem is that when i go to the new plugins page, it doesnt work, but if I copy the plugin_monitorizacion.class.php into glpi/inc (that comes with the standard glpi) it works perfect
what should be the problem?
thanks
Last edited by absport (2011-05-24 10:57:22)
Offline
Class, file and table names are standardized
The PluginMonitorizationFoo class must be stores in plugins/monitorizacion/inc/foo.php.
It it refer to a database table, this table must be glpi_pluginmonitorizationfoos
Dév. Fedora 29 - PHP 5.6/7.0/7.1/7.2/7.3/7.4 - MariaDB 10.3 - GLPI master
Certifié ITILv3 - RPM pour Fedora, RHEL et CentOS sur https://blog.remirepo.net/
Offline
You must initialize your class
file setup.php
function plugin_init_monitorizacion()
Plugin::registerClass.......
Look at plugin Example
CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6 - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)
Offline
thank you very much, but it still doesnt work, ill post my code:
setup.php
function plugin_init_monitorizacion() {
global $PLUGIN_HOOKS,$LANG,$CFG_GLPI;
Plugin::registerClass('PluginMonitorizacionTree');
$PLUGIN_HOOKS['newmenu']['monitorizacion']="/plugins/monitorizacion/inc/addmonitorizacion.class.php";
$PLUGIN_HOOKS['add_javascript']['monitorizacion']="lib/monitorizacion.js";
}
monitorizacion.class.php
<?php
class PluginMonitorizacionTree extends CommonDBTM{
static function sayhello(){
echo "<td>hola</td>";
}
}?>
monitorizacion.form.php
<?php
...
PluginMonitorizacionTree::sayhello(); //this should put "hola" in a table
...
?>
Last edited by absport (2011-05-23 17:36:02)
Offline
Your names are not corrects
You have a class TOTO, the name must be PluginMonitorizacionToto and the file's name must be toto.class.php
This class refere to a database table called glpi_plugin_monitorizacion_totos
CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6 - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)
Offline
ok, now it works, it was the files name.
Thank you very much!
Offline
Pages: 1
Topic closed