Cowboy Posted May 6, 2020 Share Posted May 6, 2020 A coupe of years ago I posted this thread and got some help about how to add and remove items from the menu using hooks. It works, to a degree, but I can't seem to remove the Store and News links from the navigation. The hook below is what I have created: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('News'))) { $primaryNavbar->removeChild('News'); } 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('News') ->removeChild('Knowledgebase') ->removeChild('Network Status'); } }); It removes the Knowledgebase and Network Status links, but not the News. Is my hook wrong? I can live with the store item being in there, but ideally I would like to remove all the menu items and add my own with custom links as I am using WordPress to supplement the site and have managed to get Avada theme to emulate the header of WHMCS (mostly). Any help with this will be appreciated. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 6, 2020 Share Posted May 6, 2020 with regards to store, you can use the IF statement from the hook below... 1 hour ago, Cowboy said: It removes the Knowledgebase and Network Status links, but not the News. Is my hook wrong? how sure are you that 'News' is actually called 'News' ? maybe you've changed its label with Language Overrides or a hook, but from your description, it sounds as though you're talking about the 'Announcements' page... if so, then change 'News' to 'Announcements' in your hook and see if that works. 1 hour ago, Cowboy said: I can live with the store item being in there, but ideally I would like to remove all the menu items and add my own with custom links as I am using WordPress to supplement the site and have managed to get Avada theme to emulate the header of WHMCS (mostly). you could loop though the navbar(s) children and remove them in a foreach loop without the need to specify each individually. 1 Quote Link to comment Share on other sites More sharing options...
Cowboy Posted May 6, 2020 Author Share Posted May 6, 2020 Ah, of course - that was it. I had renamed it loooong ago. 🙂 Thank you very much for the tip. 1 hour ago, brian! said: you could loop though the navbar(s) children and remove them in a foreach loop without the need to specify each individually. That sounds a little above my current level of understanding of WHMCS. Can you give a little more detail? 0 Quote Link to comment Share on other sites More sharing options...
Greysoul Posted May 7, 2020 Share Posted May 7, 2020 having a verify difficult time even finding the correct tpl file to edit the menu lol. from the documentation i'm reading i see navbar.tpl and header.tpl...neither of which have a hint of anything menu related in them. i got to them in the templates/theme/includes directory. what am i missing here? Thanks. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 11, 2020 Share Posted May 11, 2020 On 07/05/2020 at 03:22, Greysoul said: having a verify difficult time even finding the correct tpl file to edit the menu lol. that's because the menus are no longer edited in the template - you can do it there if you have to, but it's so messy, I wouldn't even bother. On 07/05/2020 at 03:22, Greysoul said: from the documentation i'm reading i see navbar.tpl and header.tpl...neither of which have a hint of anything menu related in them. navbar would - it's used to display the menu. On 07/05/2020 at 03:22, Greysoul said: i got to them in the templates/theme/includes directory. what am i missing here? the fact that you will have to use hooks to edit the menus. https://docs.whmcs.com/Editing_Client_Area_Menus https://docs.whmcs.com/Client_Area_Navigation_Menus_Cheatsheet if you don't want to deal with hooks, then you can always buy the Advanced Menu Manager, which creates a CSS version of the menu and allows you to easily edit it.... I think there are a couple of similar products in Marketplace too. 0 Quote Link to comment Share on other sites More sharing options...
Greysoul Posted May 12, 2020 Share Posted May 12, 2020 thanks for the help, ended up finding a hook that worked well 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.