Page 1 of 1

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

Posted: Mon Apr 09, 2018 10:02 am
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

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

Posted: Mon Apr 09, 2018 2:34 pm
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.

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

Posted: Tue Apr 10, 2018 1:33 am
by Frédéric GRANAT
Hi,
Please find attached the directories you asked for.
Frederic

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

Posted: Tue Apr 10, 2018 1:01 pm
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.

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

Posted: Wed Apr 11, 2018 2:25 am
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...

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

Posted: Wed Apr 11, 2018 11:10 am
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 :)

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

Posted: Thu Apr 12, 2018 1:30 am
by Frédéric GRANAT
Hi,
thanks,
You can close the post

Frederic