Jump to content

change name menu


swish

Recommended Posts

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:

as it is.JPG

 

How do I make it like this. Thank you

how to.JPG

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);
   }

});

Link to comment
Share on other sites

sentq's code is absolutely correct - that's the way to add a divider. :idea:

 

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')

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated