Cowboy Posted January 16, 2018 Share Posted January 16, 2018 I'm trying to find a way of switching off some items on my site's main navigation menu. I don't want to show Knowledgebase and Network Status. I have been reading the documentation (not helping me much) and watching stuff on YouTube but I think there's just something fundamentally different about the way WHMCS is presented that I am not used to. Can somebody give me a real simple, step by step "do this" so that I can remove those two items from the menu? Muchos gracias. Link to comment Share on other sites More sharing options...
WHMCS Technical Analyst II WHMCS Alex Posted January 17, 2018 WHMCS Technical Analyst II Share Posted January 17, 2018 Hello, Thank you for your post. You can use the 'ClientAreaPrimaryNavbar' hook to remove these from the client area menu - https://developers.whmcs.com/hooks-reference/client-area-interface/#clientareaprimarynavbar You may find the documentation links below help you achieve this: https://docs.whmcs.com/Editing_Client_Area_Menus https://docs.whmcs.com/Client_Area_Navigation_Menus_Cheatsheet Link to comment Share on other sites More sharing options...
Cowboy Posted January 18, 2018 Author Share Posted January 18, 2018 Thanks for the response, but I am still a bit totally lost with this stuff. What file am I supposed to be editing in order to make changes to the menu as prescribed in those links above? The documentation doesn't specify that. It talks about hooks and to be honest I can't invest time learning all that stuff when all I want to do is turn off a couple of menu items. There must surely be a simple way to do this??? Link to comment Share on other sites More sharing options...
WHMCS Technical Analyst II WHMCS Alex Posted January 18, 2018 WHMCS Technical Analyst II Share Posted January 18, 2018 Hello, Thank you for coming back to me here. If you create a .php file (calling it whatever you wish) in the /includes/hooks directory containing the code below, it will remove the 'Knowledgebase' menu when clients are not logged in. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Knowledgebase'))) { $primaryNavbar->removeChild('Knowledgebase'); } }); I hope this working example helps explain this in more detail. 1 Link to comment Share on other sites More sharing options...
Cowboy Posted January 18, 2018 Author Share Posted January 18, 2018 Aha! Thanks so much. It's made understanding the system a lot better for me now. Link to comment Share on other sites More sharing options...
brian! Posted January 18, 2018 Share Posted January 18, 2018 9 hours ago, Cowboy said: There must surely be a simple way to do this??? when you learn the basics, they're quite straightforward to use - though I still think that it was a crazy idea for WHMCS to introduce a menu system that needed hooks to modify them. to expand on @WHMCS Alex hook code, to add Network Status to it, you would do this... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Knowledgebase'))) { $primaryNavbar->removeChild('Knowledgebase'); } if (!is_null($primaryNavbar->getChild('Network Status'))) { $primaryNavbar->removeChild('Network Status'); } }); again, this only changse the menu for visitors to your site - to remove them for clients (logged in users), you could modify the above hook... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Knowledgebase'))) { $primaryNavbar->removeChild('Knowledgebase'); } if (!is_null($primaryNavbar->getChild('Network Status'))) { $primaryNavbar->removeChild('Network Status'); } if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support') ->removeChild('Knowledgebase') ->removeChild('Network Status'); } }); though then bear in mind that if you are using the "Six" template, the links to Knowledgebase and Network Status will likely be in the sidebars too, so then you'd need another hook to remove those sidebar links... e.g., a modified version of the code in the hook below... one other option for you, if you think you may be modifying these navbar and sidebars regularly, and don't want to use hooks, would be to use a third-party addon to manage the navigation link - there are a couple in Marketplace... $20 - https://marketplace.whmcs.com/product/582 $40 - https://marketplace.whmcs.com/product/1414 though I always believed that WHMCS should have added their own when they introduced the new menu in v6 - I doubt they ever will now. 1 Link to comment Share on other sites More sharing options...
Cowboy Posted January 19, 2018 Author Share Posted January 19, 2018 @brian! thank you very much for the updated hook which is very useful to me. Now that I know what's actually going on with these hooks I am sure I will be able to modify WHMCS a lot easier than I have been able to in the past. Link to comment Share on other sites More sharing options...
brian! Posted January 19, 2018 Share Posted January 19, 2018 8 hours ago, Cowboy said: Now that I know what's actually going on with these hooks I am sure I will be able to modify WHMCS a lot easier than I have been able to in the past. I should have also added that you should find plenty of similar navbar/sidebar hooks posted by myself and @sentq in these forums - so almost certainly any similar hook that you want to use will have already been posted here (or could be adapted for that purpose). Link to comment Share on other sites More sharing options...
Recommended Posts