Jump to content

Menu custom v6


manoelmendes

Recommended Posts

logged prntscr.com/8tv7eo

not logged prntscr.com/8tv7mj

 

It is showing the customer menus even off.

how to solve?

 

 

MY CODE:

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{


if (is_null($client)) {
$primaryNavbar->addChild('Meus Serviços')
->setUri('/clientarea.php?action=services')
->setOrder(10);
}

if (is_null($client)) {
$primaryNavbar->addChild('Meus Domínios')
->setUri('/clientarea.php?action=domains')
->setOrder(20);
}

if (is_null($client)) {
$primaryNavbar->addChild('Minhas Faturas')
->setUri('/clientarea.php?action=invoices')
->setOrder(30);
}
if (is_null($client)) {
$primaryNavbar->addChild('Meus Tickets')
->setUri('/supporttickets.php')
->setOrder(40);
}


if (!is_null($primaryNavbar->getChild('Support'))) {
$primaryNavbar->removeChild('Support');
}

if (!is_null($primaryNavbar->getChild('Services'))) {
$primaryNavbar->removeChild('Services');
}

if (!is_null($primaryNavbar->getChild('Billing'))) {
$primaryNavbar->removeChild('Billing');
}
if (!is_null($primaryNavbar->getChild('Domains'))) {
$primaryNavbar->removeChild('Domains');
}


});

?>

Edited by Infopro
Please Attach Images to Your Posts.
Link to comment
Share on other sites

you haven't defined the $client variable in the hook, so you need to do that...

 

the start of the hook should be...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
$client = Menu::context('client');

Link to comment
Share on other sites

I added the line, however, the menu appears only for those who are not logged in.

 

- - - Updated - - -

 

Logged http://prntscr.com/8u439t

Not logged http://prntscr.com/8u431x

 

 

However, only appears when you are not logged in.

 

 

SCRIPTS USED:

 

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

}

});

Link to comment
Share on other sites

i'm not exactly sure what you're trying to do, but I think you want to remove the dropdown menus from the client area.

 

if so, the best way would be to remove the children using a hook... the next best way, would be to do what you have tried and remove the menu parts with dropdowns and add them again.

 

try the following...

 

 <?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
$client = Menu::context('client'); 

if (!is_null($primaryNavbar->getChild('Support'))) {
   $primaryNavbar->removeChild('Support');
}

if (!is_null($primaryNavbar->getChild('Services'))) {
   $primaryNavbar->removeChild('Services');
}

if (!is_null($primaryNavbar->getChild('Billing'))) {
   $primaryNavbar->removeChild('Billing');
}
if (!is_null($primaryNavbar->getChild('Domains'))) {
   $primaryNavbar->removeChild('Domains');
}

if (!is_null($client)) {
   $primaryNavbar->addChild('Services',array(
               'label' => Lang::trans('navservices'),
               'uri' => 'clientarea.php?action=services',
               'order' => '10',
           ));
}

if (!is_null($client)) {
   $primaryNavbar->addChild('Domains',array(
               'label' => Lang::trans('navdomains'),
               'uri' => 'clientarea.php?action=domains',
               'order' => '20',
           ));
}

if (!is_null($client)) {
   $primaryNavbar->addChild('Billing',array(
               'label' => Lang::trans('navbilling'),
               'uri' => 'clientarea.php?action=invoices',
               'order' => '30',
           ));
}

if (!is_null($client)) {
   $primaryNavbar->addChild('Billing',array(
               'label' => Lang::trans('navbilling'),
               'uri' => 'clientarea.php?action=invoices',
               'order' => '30',
           ));
}

if (!is_null($client)) {
   $primaryNavbar->addChild('Support',array(
               'label' => Lang::trans('navtickets'),
               'uri' => 'supporttickets.php',
               'order' => '40',
           ));
}
});

?>

if I use the above hook and change the language to Portugese-br, I see...

 

zmrtxX7.png

 

you might not even need to check if the client is logged in, so the following simpler hook might work too...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{

if (!is_null($primaryNavbar->getChild('Support'))) {
   $primaryNavbar->removeChild('Support')
               ->addChild('Support',array(
               'label' => Lang::trans('navtickets'),
               'uri' => 'supporttickets.php',
               'order' => '40',
           ));
}

if (!is_null($primaryNavbar->getChild('Services'))) {
   $primaryNavbar->removeChild('Services')
               ->addChild('Services',array(
               'label' => Lang::trans('navservices'),
               'uri' => 'clientarea.php?action=services',
               'order' => '10',
           ));
}

if (!is_null($primaryNavbar->getChild('Billing'))) {
   $primaryNavbar->removeChild('Billing')
               ->addChild('Billing',array(
               'label' => Lang::trans('navbilling'),
               'uri' => 'clientarea.php?action=invoices',
               'order' => '30',
           ));
}

if (!is_null($primaryNavbar->getChild('Domains'))) {
   $primaryNavbar->removeChild('Domains')
               ->addChild('Domains',array(
               'label' => Lang::trans('navdomains'),
               'uri' => 'clientarea.php?action=domains',
               'order' => '20',
           ));
}
});

?>

if you want to change the text in the above menu, do not use a hook - use Language Overrides...

 

http://docs.whmcs.com/Language_Overrides

 

the above documentation will tell you in more detail, but create a folder in the "lang" directory and call it "overrides" - inside this folder, add a new file called portuguese-br.php and add the following code to it...

 

<?php
$_LANG['navservices'] = "Meus Serviços";
$_LANG['navdomains'] = "Meus Domínios";
$_LANG['navbilling'] = "Minhas Faturas";
$_LANG['navtickets'] = "Meus Tickets";

and then your client area menu should look like...

 

295ae85ebcb341cda543982db15462eb.png

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