How to add a menu item in the "Home" menu

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

How to add a menu item in the "Home" menu

Post by Frédéric GRANAT »

Hi,
I want to add 1 menu Item "Operations center CD04 - Support" in the "Home" left menu (In the Quickview)
I've got currently from top to bottom :
Home dashboard
Tactical overview
Birdseye
Operation screen
Operations center
Operations center CD04 (a previous customed item)

I want to add my item bellow Operations center CD04
I created a directory for my menu item in /usr/local/nagiosxi/html/includes/components

for that item I wrote a inc.php file with the following code in the function xxx_component_addmenu

Code: Select all

 $neworder=$order+0.1; //determine my menu order


Now I can't see my new item and the following items disappeared :
Operations center
Operations center CD04

My menu is now :
Home dashboard
Tactical overview
Birdseye
Operation screen
Open service problem
...

Please tell me how to add my menu item (and display the menu items that disappeared)

I attached all the include files for menu items :
Operation screen
Operations center
Operations center CD04
Operations center CD04 - Support

Rgds,

Frederic
You do not have the required permissions to view the files attached to this post.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: How to add a menu item in the "Home" menu

Post by npolovenko »

Hello, Frédéric GRANAT. Usually, when components disappear it means you still have configs that don't point to the right files or don't have a unique id. If two components have the same id somewhere that can cause the issue you're having. I'd like to see all files that belong to the Operations center CD04 - Support component, as well as well as all the files from the Operations center CD04 component so that I could compare them.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

Re: How to add a menu item in the "Home" menu

Post by Frédéric GRANAT »

Hi,
Please find attached the directories you asked for.
Frederic
You do not have the required permissions to view the files attached to this post.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: How to add a menu item in the "Home" menu

Post by npolovenko »

Frédéric GRANAT, Disclaimer: I'm not a developer. But I've corrected a few lines in your component and it worked for me. I'm attaching the modified zip file. Let me know if it works for you.

If the menu items still getting shifted you may add a separate entry with a unquie "id" in:

Code: Select all

/usr/local/nagiosxi/html/includes/utils-menu.inc.php

Code: Select all

  add_menu_item(MENU_HOME, array(
        "type" => "link",
        "title" => _("Operations Center CD04 - Support"),
        "id" => "menu-home-operations_center_support",
        "order" => 112,
         "opts" => array(
            "href" => "/nagiosxi/includes/components/operations_center_support/operations_center_support.php"
        )
    ));
And then in the inc.php file:
$mi=find_menu_item(MENU_HOME,"menu-home-operations_center_support","id");

But only if the attached component doesn't work.
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

Re: How to add a menu item in the "Home" menu

Post by Frédéric GRANAT »

Hi,
Thank you very much, it works fine (without modifying /usr/local/nagiosxi/html/includes/utils-menu.inc.php)
I saw your change : $mi=find_menu_item(MENU_HOME,"menu-home-tacticaloverview","id");
So every new component has to be located after "tactical overview" (I located a component after the previous one).
I must admit I don't understand the logic behind that.

If you have any explanation about that...
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: How to add a menu item in the "Home" menu

Post by npolovenko »

[user]Frédéric GRANAT[/user],Glad it worked! So this line:
$mi=find_menu_item(MENU_HOME,"menu-home-tacticaloverview","id");
Looks if there's a menu-home-tacticaloverview entry in the MENU_HOME array.

The MENU_HOME array is initialized here:

Code: Select all

/usr/local/nagiosxi/html/includes/utils-menu.inc.php
What you had before was:
$mi=find_menu_item(MENU_HOME,"menu-home-operations_center","id");
There is no such entry in the MENU_HOME array, you can check in the /usr/local/nagiosxi/html/includes/utils-menu.inc.php file.

That resulted in this:

Code: Select all

if($mi==null) //bail if I didn't find the above menu item 
		return;
So i just randomly picked some entry that does exist in that file :)
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

Re: How to add a menu item in the "Home" menu

Post by Frédéric GRANAT »

Hi,
thanks,
You can close the post

Frederic
Locked