Jump to content

how to remove some sidbars? (six template)


hardbrasil

Recommended Posts

hello fellas,

 

i am trying to remove some sidebars and without success.

 

i am using this code that support told me but i got an error on aplication

 

<?php

use WHMCS\View\Menu\Item as MenuItem;
if (!is_null($primarySidebar->getChild('Client Shortcuts'))) {
add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) {
$primarySidebar->removeChild('Client Shortcuts');
}
);

 

please see wich one i went to remove

 

print.gif

txk advanced

Edited by hardbrasil
Link to comment
Share on other sites

the contacts and client shortcuts can be removed using the method in the thread below...

 

http://forum.whmcs.com/showthread.php?111163-Hook-to-remove-Contacts-Sub-Accounts&p=452734#post452734

 

the Recent News panel can also be removed in the same file...

 

so create a .php file in includes/hooks, give it a filename and add the following code to it...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar)
{
   if (!is_null($secondarySidebar->getChild('Client Contacts'))) {
               $secondarySidebar->removeChild('Client Contacts');
   }

   if (!is_null($secondarySidebar->getChild('Client Shortcuts'))) {
               $secondarySidebar->removeChild('Client Shortcuts');
   }

});

add_hook('ClientAreaHomepagePanels', 1, function (MenuItem $homePagePanels)
{
   if (!is_null($homePagePanels->getChild('Recent News'))) {
               $homePagePanels->removeChild('Recent News');
   }
});

Link to comment
Share on other sites

Hi Brian,

 

i create this hook using your sintax to remove a especific item of sidebar menu,

actually works, but when i change page i got an error,

 

this is the code

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
   $primarySidebar->getChild('My Account')
       ->removeChild('Contacts/Sub-Accounts');
});

 

the error is:

 

Fatal error: Call to a member function removeChild() on null in /var/www/vhosts/gleads.com.br/fin.gleads.com.br/includes/hooks/remove_item_sidebar.php on line 8

 

thanks

Link to comment
Share on other sites

Hi,

 

you need to check that what you want to remove exists *before* you try to remove it - otherwise, it will work fine on pages where it exists, but cause an error when it doesn't.

 

so, try using...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
   if (!is_null($primarySidebar->getChild('My Account'))) {
               $primarySidebar->removeChild('Contacts/Sub-Accounts');
   }
});  

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