snake Posted April 18, 2020 Share Posted April 18, 2020 I am trying to add a couple of custom menu items. I have managed to add a child to the primary menu but I cannot get the secondary menu addition to work. please note that I am not a php developer, I am just doing this from reading the docs. Here is what I have, can someone fix my code... thanks. <?php use WHMCS\View\Menu\Item as MenuItem; /** this one works **/ add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $primaryNavbar->addChild('Main Website') ->setUri('https://foodbooking.uk/') ->setOrder(2); }); /** this one doesn't work , in fact this code stops the one above from working too**/ add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar) { if (!is_null($secondaryNavbar->getChild('Account'))) { $secondaryNavbar->getChild('Account') ->addChild('Restaurant Login', array( 'label' => 'Restaurant Login'), 'uri' => 'https://restaurantlogin.com', 'order' => '100', )); } }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 18, 2020 Share Posted April 18, 2020 3 hours ago, snake said: please note that I am not a php developer, I am just doing this from reading the docs. mistake number #1 lol 😛 3 hours ago, snake said: Here is what I have, can someone fix my code... thanks. you've left a closing bracket in the Restaurant Login label line... 'label' => 'Restaurant Login', technically, you don't even need that entire line - if you remove it, the hook will still work and will just use the child's name - which is "Restaurant Login" anyway. 0 Quote Link to comment Share on other sites More sharing options...
snake Posted April 18, 2020 Author Share Posted April 18, 2020 thanks, all working now 🙂 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.