willk Posted April 1, 2019 Share Posted April 1, 2019 Hi All, For some reason the tabAddons nav option is not displaying on random products, even though there are addons definitely available for them. To get around this I wanted to add a custom nav item using the ClientAreaPrimarySidebar hook. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $client = Menu::context("client"); $pid = (int) $client->id; if (!is_null($primarySidebar->getChild('Service Details Actions'))) { $primarySidebar->getChild('Service Details Actions') ->addChild('Order Addons') ->setOrder(100) ->setUri('../clientarea.php?action=productdetails&id='.$pid.'#tabAddons'); } }); Although I can get the client ID using the Menu::context option I cannot work out how get the current productID. Any suggestions would be appreciated. Thanks, Will 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 2, 2019 Share Posted April 2, 2019 the hook below would work... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $service = Menu::context('service'); $pid = (int) $service->id; if (!is_null($primarySidebar->getChild('Service Details Actions'))) { $primarySidebar->getChild('Service Details Actions') ->addChild('Order Addons') ->setOrder(100) ->setUri('clientarea.php?action=productdetails&id='.$pid.'#tabAddons'); } }); though I might be more tempted to add it to the Overview sidebar (perhaps detecting if there was already an addons link there, and checking that the service is active). 0 Quote Link to comment Share on other sites More sharing options...
willk Posted April 2, 2019 Author Share Posted April 2, 2019 Hi Brian, Fantastic, thanks for your reply. I took your advice and checked to see if the Addons was menu item was null or not before adding it again. However, the Uri when it is added seems to reload the entire page and then lose the product ID. I have commented out the check for Addons in the template file so the class with ID 'tabAddons' definitely exists on the page. See: http://prntscr.com/n6n1v4 The menu item renders okay, see: http://prntscr.com/n6n207 However, it doesn't have the data-toggle="tab" field so it does a postback of the entire page and loses the productID etc. so if you click back on 'Information' it no longer shows anything. I couldn't find any set commands when adding the child to fix this. Thanks, Will 1 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 3, 2019 Share Posted April 3, 2019 Hi Will, 15 hours ago, willk said: However, it doesn't have the data-toggle="tab" field so it does a postback of the entire page and loses the productID etc. so if you click back on 'Information' it no longer shows anything. I couldn't find any set commands when adding the child to fix this. just add the code below to your hook... ->setAttribute('dataToggleTab','tab') 0 Quote Link to comment Share on other sites More sharing options...
willk Posted April 4, 2019 Author Share Posted April 4, 2019 Thanks Brian, you are a star! 0 Quote Link to comment Share on other sites More sharing options...
NadalKumar Posted April 4, 2019 Share Posted April 4, 2019 There's a bit more attribute flexibility if the array method is used ->setAttributes(['class' => 'myclass dropdown-toggle', 'data-toggle' => 'dropdown']) // and if an icon is desired ->setIcon('fas fa-chevron-up') 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.