Ad Widget

Collapse

Zabbix Custom Module Contact Info Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kmitadmin
    Junior Member
    • Jan 2021
    • 13

    #1

    Zabbix Custom Module Contact Info Help

    I originally started the below thread but realized I was working on the wrong thing so I've created a new thread.


    I've put together a simple module to add a new menu item to my Zabbix 5.2 install. My problem is I can't figure out how to get it to open a URL in a new window. I found a feature called setURL but couldn't get that to work right. Does anyone know how to make a menu item open into a new window? See code below

    public function init(): void {
    // Initialize main menu (CMenu class instance).
    APP::Component()->get('menu.main')
    ->insertAfter(_('Administration'),((new \CMenuItem(_('Outage Contacts')))
    ->setAction('myserver.com/OutageContacts.html'))
    );
    }

    Zabbix Manual I'm Using For This

  • kmitadmin
    Junior Member
    • Jan 2021
    • 13

    #2
    For anyone who may see this post. I was able to get the URL working with the below code in Modules.php but I haven't figured out how to open a new window. This will cover me for now and when I have time I may read the documentation more and figure it out.

    Complete Module.php file:
    Code:
    <?php declare(strict_types = 1);
    
    namespace Modules\AddContactInfoMenu;
    
    use APP;
    use CController as CAction;
    
    /**
    * Please see Core\CModule class for additional reference.
    */
    class Module extends \Core\CModule {
    
    /**
    * Initialize module.
    */
    public function init(): void {
    // Initialize main menu (CMenu class instance).
    APP::Component()->get('menu.main')
    ->insertAfter(_('Administration'),((new \CMenuItem(_('Outage Contacts')))
    ->setUrl(new \CUrl('http://myserver.local/OutageContacts.html')))
    );
    }
    
    /**
    * Event handler, triggered before executing the action.
    *
    * @param CAction $action Action instance responsible for current request.
    */
    public function onBeforeAction(CAction $action): void {
    }
    
    /**
    * Event handler, triggered on application exit.
    *
    * @param CAction $action Action instance responsible for current request.
    */
    public function onTerminate(CAction $action): void {
    }
    }
    Complete manifest.json file:

    {
    "manifest_version": 1.0,
    "id": "add_contact_info_menu",
    "name": "Add Info In Menu",
    "version": "1.0",
    "namespace": "AddContactInfoMenu",
    "author": "My Name",
    "url": "https://notavailable.com",
    "description": "Add Contact Info Menu To Side Bar."
    }


    Comment

    Working...