Jump to content

Multiple Nav Hooks


CobbyJ

Recommended Posts

Hello,

 

In my hooks im trying to add 2 hooks

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

and

if add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar)

But i keep getting an error. does anyone know the correct to code it.

My current file is

-------------------------------------------------------------------------------------------------------------------------------------

<?php
if ( !defined('WHMCS')) {
    header("Location: ../../index.php");
}

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    if (!is_null($primaryNavbar->getChild('Network Status'))) {
        $primaryNavbar->removeChild('Network Status');
        }
       if (!is_null($primaryNavbar->getChild('Announcements'))) {
        $primaryNavbar->removeChild('Announcements');
    }
           if (!is_null($primaryNavbar->getChild('Knowledgebase'))) {
        $primaryNavbar->removeChild('Knowledgebase');
    }
               if (!is_null($primaryNavbar->getChild('Contact Us'))) {
        $primaryNavbar->removeChild('Contact Us');
    }
                   if (!is_null($primaryNavbar->getChild('Store'))) {
        $primaryNavbar->removeChild('Store');
    }
                       if (!is_null($primaryNavbar->getChild('Home'))) {
        $primaryNavbar->removeChild('Home');
    }

});

-------------------------------------------------------------------------------------------------------------------------------------

I want to add this

-------------------------------------------------------------------------------------------------------------------------------------

 

use WHMCS\View\Menu\Item as MenuItem;

if add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar)
{
   $client = Menu::context('client');
   if (!is_null($client)) {
       if (!is_null($secondarySidebar->getChild('Support'))) {
               $secondarySidebar->getChild('Support')
                               ->removeChild('Announcements')
                               ->removeChild('Knowledgebase')
                               ->removeChild('Downloads')
                               ->removeChild('Network Status')
                               ->removeChild('Open Ticket');
       }
   }
});



-------------------------------------------------------------------------------------------------------------------------------------

Any help would be greatful.

Edited by WHMCS ChrisD
Moved code into code box, please use the <> button to add in the future
Link to comment
Share on other sites

change sidebar code to this:

add_hook('ClientAreaSecondarySidebar', 1, function($secondarySidebar)
{
    $client = Menu::context('client');
    if (!is_null($client) && !is_null($secondarySidebar->getChild('Support'))) {
            $support = $secondarySidebar->getChild('Support');
            
            if (!is_null($support->getChild('Announcements'))){
                $support->removeChild('Announcements');
            }
            if (!is_null($support->getChild('Knowledgebase'))){
                $support->removeChild('Knowledgebase');
            }
            if (!is_null($support->getChild('Downloads'))){
                $support->removeChild('Downloads');
            }
            if (!is_null($support->getChild('Network Status'))){
                $support->removeChild('Network Status');
            }
            if (!is_null($support->getChild('Open Ticket'))){
                $support->removeChild('Open Ticket');
            }
    }
});

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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