Turn off horizontal menu

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
ethanlazarus
User
Posts: 71

Turn off horizontal menu

Post by ethanlazarus »

Hello - I am still trying to upgrade from 2018 to 2024 - thanks for all the tips so far!
I finally have the project loading, but did a ton of custom menus in 2018 - they are all supposed to just show in the vertial menu bar. However, they are all showing in the horizontal menu bar as well. Is there a way to just turn off horizontal menu completely for all menu items?
If not, how do I adjust my menu adding code so it is not specified as a navbar item? I'm not sure what each variable means in the addmenu command. Example:
$this->AddMenuItem(291291291, "name",cleanstring($htext), $texting_link , -1,"",IsLoggedIn(),0,1);


mobhar
User
Posts: 11910

Post by mobhar »

Make sure you have already unchecked the Navbar Item option from Tools -> Menu Editor for the menu items you do not want to be shown up on Navbar.


ethanlazarus
User
Posts: 71

Post by ethanlazarus »

Thank you so much - these are added as custom code, not in the menu editor - they get populated by the database (for example, messages waiting, etc). So I can't turn off navbar item on menu- is there a way just to completely disable the horizontal nav bar, or to modify the addmenuitem options to specify it is not navbar? Thanks!


mobhar
User
Posts: 11910

Post by mobhar »

It actually depends on the custom code you mentioned. Did you use MenuItem_Adding server event to load the menu items from database? Which PHPMaker version are you using?


ethanlazarus
User
Posts: 71

Post by ethanlazarus »

I am using phpmaker 2024 (upgrading from 2018). I needed to put all the codes in menu_rendering event to get them to show. As an example, I have a "Tests" menu that gets added, and then a bunch of sub-menus get added to this one. But the "Tests" menu ends up both on the left nav and the horizontal nav. there are several thousand lines of code. But it is all called from the menu_rendering event. This would be an example of the code that creates the top-level menu item:

$this->AddMenuItem(9000, "name",$testsmenu, "", -1,"",IsLoggedIn(),0);

Then other items are added to this "tests" menu afterwards. I need all this to only show on the left menu. If possible, is there a way just to disable horizontal nav, or is there a code that would prevent it from showing? It is making the chart unreadable.

Thank you again.


mobhar
User
Posts: 11910

Post by mobhar »

You may check the addMenuItem method in src/Menu.php file, see the following code:

...
    // Add a menu item ($src for backward compatibility only)
    public function addMenuItem(
        $id,
        $name,
        $text,
        $url,
        $parentId = -1,
        $src = "",
        $allowed = true,
        $isHeader = false,
        $isCustomUrl = false,
        $icon = "",
        $label = "",
        $isNavbarItem = false,
        $isSidebarItem = false
    ) {
...

As you can see, the last two param, which is $isNavbarItem and $isSidebarItem will identify whether the menu item will be shown in Navbar and Sidebar respectively, if the value is set to true.

In addition, you may refer to the code in views/menu.php file, how to place the menu items in Sidebar and/or Navbar.


ethanlazarus
User
Posts: 71

Post by ethanlazarus »

I still cannot prevent menu items from appearing on horizontal nav -

if the URL is specified as anything but blank, item shows on horizontal menu - so this still shows on horizontal menu:
$this->AddMenuItem(48573498, "testingmenu", "testing menu", "#", -1, "",
true, false, false, "", "", false, false);

If I clear the URL, even if set last 2 variables to true, does NOT show:
$this->AddMenuItem(48573498, "testingmenu", "testing menu", "", -1, "",
true, false, false, "", "", true, true);

Only way I seem to be able to prevent the horizontal menu is to edit the views/menu.php - and comment out line 7:

// Navbar menu
$topMenu = new Menu("navbar", true, true);
//echo $topMenu->toScript();

This is fine, but then every time I regenerate my files, the menu will show again - any idea if there is either a problem with how I'm calling the addmenuitem, or if I can code just to turn off topmenu without it turning back on each time I regenerate files?

Thanks again. 


mobhar
User
Posts: 11910

Post by mobhar »

mobhar wrote:

Make sure you have already unchecked the Navbar Item option from Tools -> Menu Editor for the menu items you do not want to be shown up on Navbar.

As mentioned, you should disable the Navbar Item option from Menu Editor.

After that, you may then use Menu_Rendering server event to load your desired menu items only for the Sidebar.


Post Reply