dakeister Posted September 30, 2015 Share Posted September 30, 2015 <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $client = Menu::context('client'); // only add menu item when no client logged in if (is_null($client)) { $primaryNavbar->addChild('Example') ->setUri('https://www.example.com/') ->setOrder(100); } }); I have used the above code to add links to our control panel which works Ok but I would like to make a drop down list under Client Portals for Websitepanel, webmail, and web stats. New to PHP any help with code would be extremely grateful. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 30, 2015 Share Posted September 30, 2015 if you're talking about the navbar, you just need to add more children to your link and it will add the dropdown... see the code below as an example - you probably won't need the separator part.. http://forum.whmcs.com/showthread.php?99967-Nav-Links&p=437143#post437143 0 Quote Link to comment Share on other sites More sharing options...
dakeister Posted September 30, 2015 Author Share Posted September 30, 2015 Thanks for the help Brian but I tried that it didn't work just get a blank page. I did this code first; <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $client = Menu::context('client'); // only add menu item when no client logged in if (is_null($client)) { $primaryNavbar->addChild('Client Portals') ->setOrder(100); } }); And saved it as ClientPortal.php which gives me the Tab Client Portals. The page will load and the nave bar is present. Then I added this code to ClientPortal1.php; <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $primaryNavbar->getChild('Client Portals') ->addChild('Remote Support', array( 'label' => 'Remote Support', 'uri' => 'http://www.mdcdnn.net:8040', 'order' => '200', )); $primaryNavbar->getChild('Client Portals') ->addChild('Divider', array( 'order' => '300', )) ->setClass('nav-divider'); $primaryNavbar->getChild('Client Portals') ->addChild('Web Mail', array( 'label' => 'Web Mail', 'uri' => 'http://webmail.mdcdnn.net', 'order' => '400', )); $primaryNavbar->getChild('Client Portals') ->addChild('Divider', array( 'order' => '500', )) ->setClass('nav-divider'); $primaryNavbar->getChild('Client Portals') ->addChild('Web Stats', array( 'label' => 'Web Stats', 'uri' => 'http://stats.mdcdnn.net', 'order' => '600', )); } }); Which just gives me a blank page. I have also removed the divider tags which gives me the same results. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 30, 2015 Share Posted September 30, 2015 Hi, Thanks for the help Brian but I tried that it didn't work just get a blank page. a blank page? welcome to coding WHMCS hooks. i'm unsure why you're trying to use two separate hooks to do this - I guess you could if you really needed to, but certainly not the way you're trying it! what I would do is just edit clientportal.php and add the code below (and delete clientportal1.php)... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $client = Menu::context('client'); // only add menu item when no client logged in if (is_null($client)) { $primaryNavbar->addChild('Client Portals') ->setOrder(100); $primaryNavbar->getChild('Client Portals') ->addChild('Remote Support', array( 'label' => 'Remote Support', 'uri' => 'http://www.mdcdnn.net:8040', 'order' => '200', )); $primaryNavbar->getChild('Client Portals') ->addChild('Divider1', array( 'order' => '300', )) ->setClass('nav-divider'); $primaryNavbar->getChild('Client Portals') ->addChild('Web Mail', array( 'label' => 'Web Mail', 'uri' => 'http://webmail.mdcdnn.net', 'order' => '400', )); $primaryNavbar->getChild('Client Portals') ->addChild('Divider2', array( 'order' => '500', )) ->setClass('nav-divider'); $primaryNavbar->getChild('Client Portals') ->addChild('Web Stats', array( 'label' => 'Web Stats', 'uri' => 'http://stats.mdcdnn.net', 'order' => '600', )); } }); this should now show the dropdown to anyone who is *not* logged in. also, it's worth remembering that children names must be unique - so you can't have two children called 'Divider', so in the above code, i've numbered them 1 & 2 to make their names different. 0 Quote Link to comment Share on other sites More sharing options...
dakeister Posted September 30, 2015 Author Share Posted September 30, 2015 Hay Brian it works perfectly, thanks for your help. 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.