manoelmendes Posted October 21, 2015 Share Posted October 21, 2015 (edited) 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 October 22, 2015 by Infopro Please Attach Images to Your Posts. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 22, 2015 Share Posted October 22, 2015 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'); 0 Quote Link to comment Share on other sites More sharing options...
manoelmendes Posted October 26, 2015 Author Share Posted October 26, 2015 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); } }); 0 Quote Link to comment Share on other sites More sharing options...
Deimantas Posted October 26, 2015 Share Posted October 26, 2015 use this for logged in: {if $loggedin}, and this for logged out: {if !$loggedin} 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 26, 2015 Share Posted October 26, 2015 use this for logged in: {if $loggedin}, and this for logged out: {if !$loggedin} you can't use that with hooks. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 26, 2015 Share Posted October 26, 2015 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... 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... 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.