Dora
Dora

Reputation: 285

How to add new menu with submenus in WHMCS?

I wanted to add a new custom menu with submenus, and researched on official WHMCS documentation, but found only this:

<?php
#adding Menu Item to primaryNavbar
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
$primaryNavbar->addChild('Menu Name')
    ->setUri('https://www.example.com/')
    ->setOrder(70);
});

But question is, how to add menu with submenus inside?

Upvotes: 1

Views: 1821

Answers (2)

HMaddy
HMaddy

Reputation: 1

Login to your whmcs installation folder -> includes -> hooks folder

create a new php file with the above code.

Edit the Menu name, https://www.example.com/ with your details and save the file

Thats all!

Upvotes: 0

n8whnp
n8whnp

Reputation: 296

So a menu with sub menu items in WHMCS's client interface is just a menu item with children. The example code you cite creates a menu item, to make sub menus just add more children to the result of your addChild() call. Like this:

use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    $menuItem = $primaryNavbar->addChild('Menu Name')
        ->setUri('https://www.example.com/')
        ->setOrder(70);
    $menuItem->addChild('Sub Menu Item 1')->setUri('foo');
    $menuItem->addChild('Sub Menu Item 2')->setUri('bar');
    return $primaryNavbar;
});

Upvotes: 2

Related Questions