Jump to content

Using hooks to change sidebar menus - works on some pages, blank screens on others


Recommended Posts

I've been trying to add and remove items from the primary top and sidebar menus in Six.

 

My hangup currently is that I have a hook php file that is set to remove the RSS Feeds option.

 

I have it saved as its own hook file (remove-primarysidebar.php) with the following:

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
   $primarySidebar->getChild('Network Status')
       ->removeChild('View RSS Feed');
});

 

On the Network status page, that works perfectly. The menu item in the primary sidebar is now gone. However, when I click to another page (Affiliates, Contact, etc) the pages all load blank. I've cleared the templates_c out and can confirm that the hook file above is the culprit.

 

The same thing happens for a separate hook file I created to remove items from the secondary menu. I had it set to remove Announcements, Knowledgebase, Downloads, etc. And it works perfectly on the Network Status page. But if you click to any other page (including the ordering process) at all they are blank/white screens.

 

Something in the sample code I have above breaks every other page besides Network Status when uploaded.

 

Am I missing something?

 

TIA,

Jason

Link to comment
Share on other sites

Jason,

 

try the following hook...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
if (!is_null($primarySidebar->getChild('Network Status'))) {
                $primarySidebar->getChild('Network Status')
                                          ->removeChild('View RSS Feed');
   }
});

Link to comment
Share on other sites

  • 2 years later...

Can you help? Trying to translate a Primary Sidebar Item.
This little Hooks works on the Domains pages where the Primary Sidebar is shown but gives me an "Ooops"-error on all other pages:

<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
    $primarySidebar->getChild('Domain Details Management')
            ->getChild('Change Owner')
            ->setLabel('Inhaber wechseln');
});

Now I tried to adapt the code listed above but this doesn't even work on the Domains page (Ooops):

<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
if (!is_null($primarySidebar->getChild('Domain Details Management'))) {
            $primarySidebar->getChild('Change Owner')
                           ->setLabel('Inhaber wechseln');
    }
});

What am I doing wrong here?
Thank you!! Biting in my chair :9)

Link to comment
Share on other sites

Now I have it - IT WORKS!!! Sorry guys - moderator may delete or leave here for educational purposes :-)

<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
if (!is_null($primarySidebar->getChild('Domain Details Management'))) {
            $primarySidebar->getChild('Domain Details Management')
                    ->getChild('Change Owner')
                        ->setLabel('Inhaber wechseln');
    }
});

 

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