swish Posted September 19, 2016 Share Posted September 19, 2016 Hello, I need to move a partition Open the ticket in another section I have everything worked out, but there is a problem in the following add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Open Ticket'))) { $primaryNavbar->removeChild('Open Ticket'); } if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support') ->addChild('Open Ticket', array( 'label' => Lang::trans('navopenticket'), 'uri' => 'submitticket.php', 'order' => '1', )); } }); But I would like to draw a line between sections. It turned out this way: How do I make it like this. Thank you 0 Quote Link to comment Share on other sites More sharing options...
twhiting9275 Posted September 19, 2016 Share Posted September 19, 2016 Firstly, your code, as posted isn't going to work. Take a look at the code I posted below and modify it. This code does, indeed work Secondly, unfortunately, there's no documented way to do what you're after. None of the menu documentation has any hint at adding anything for the divider class, though, I fully agree that it should. I know WHMCS themselves do it, because it shows up all over the place in the menu, but I'm not so certain that's a hook itself, more like something hard coded. That said, what you are after can be achieved, using the following code: <?php add_hook('ClientAreaPrimaryNavbar', 1, function ($primaryNavbar) { if (!is_null($primaryNavbar->getChild('Open Ticket'))) { $primaryNavbar->removeChild('Open Ticket'); } if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support') ->addChild('Open Ticket', array( 'label' => Lang::trans('navopenticket'), 'uri' => 'submitticket.php', 'order' => '1', )); $primaryNavbar->getChild('Support') ->addChild('divider', array( 'label' => '----', 'uri' => '#', 'order' => '2', )); } }); Add whatever else you're after and increase the order as you like. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted September 19, 2016 Share Posted September 19, 2016 Hi Swish, your function seems pretty valid to me, what you are missing is the Divider, and here is how to apply it: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook("ClientAreaPrimaryNavbar", 1, function (MenuItem $primaryNavbar){ if (!is_null($primaryNavbar->getChild('Open Ticket'))) { $primaryNavbar->removeChild('Open Ticket'); } if (!is_null($primaryNavbar->getChild('Support'))){ $primaryNavbar->getChild('Support') ->addChild('Open Ticket') ->setURI('submitticket.php') ->setLabel(Lang::trans('navopenticket')) ->setOrder(1); # Add Divider Right After "Open Ticket" Link $primaryNavbar->getChild('Support') ->addChild('Divider') ->setClass('nav-divider') ->setOrder(2); } }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 20, 2016 Share Posted September 20, 2016 sentq's code is absolutely correct - that's the way to add a divider. but if you want to add another divider to the same sub-menu, then you need to remember that child names need to be unique - so you would need to use 'Divider2' etc for future dividers... ->addChild('Divider2') 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.