DCTHost Posted July 12, 2016 Share Posted July 12, 2016 Hi all, I'm trying to make a dropdown menu on my Navbar called "Legal" which displays "Privacy Policy" and "ToS". Currently, this is only displaying the "Legal" dropdown menu and then only the "Privacy Policy". <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $primaryNavbar->addChild('Legal') ->setOrder(70); }); add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Legal'))) { $primaryNavbar->getChild('Legal') ->addChild('Emergency Contacts', array( 'label' => 'ToS', 'uri' => 'http://dct.host/index.php?m=TermsOfService', 'order' => '100', )); } }); add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Legal'))) { $primaryNavbar->getChild('Legal') ->addChild('Emergency Contacts', array( 'label' => 'Privacy Policy', 'uri' => 'http://dct.host/index.php?m=PrivacyPolicy', 'order' => '100', )); } }); Any ideas? - - - Updated - - - PLEASE NOTE I fixed this as soon as I had posted it! Have requested for the topic to be removed. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 12, 2016 Share Posted July 12, 2016 assuming the thread doesn't get deleted, for others reading it, there are a few things wrong with the above hook... 1. if the hook is creating the children, you don't need to check that they exist - they will, because you're creating them! 2, children can't have the same name - so you can't have two children called 'Emergency Contacts'. 3. having two children with the same order value is pointless - they'd be shown in alphabetical order. 4. if you name the child what you want it's label to be, you don't need to set a separate label in the hook. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $primaryNavbar->addChild('Legal') ->setOrder(70); $primaryNavbar->getChild('Legal') ->addChild('ToS', array( 'uri' => 'index.php?m=TermsOfService', 'order' => '10', )); $primaryNavbar->getChild('Legal') ->addChild('Privacy Policy', array( 'uri' => 'index.php?m=PrivacyPolicy', 'order' => '20', )); }); 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.