Jump to content
CCSupport

Remove Menu Items - v6

Recommended Posts

Hello all,

 

I would like to remove some of the menu items on the main Nav & sidebar within WHMCS v6.

 

After reading this page I am pretty confused as to how to simply remove the link/item altogether.

 

In essence, I need to remove Network Status from the 'Support' dropdown including the sidebar and also want to remove the 'Order Hosting' from the main homepage where it states "How can we help today?"

 

Any assistance or guidance to the right file(s) would be appreciated.

Share this post


Link to post
Share on other sites

Fantastic, thank you :-)

 

- - - Updated - - -

 

Just to check, as I have never added hooks before, do I need to name the .php file something specific or can it be anything as long as it is in the /hooks folder? I ask as I have just created a file named 'removenetwork.php' and added the remove network status example code but it did nothing....guessing I am missing something!

Share this post


Link to post
Share on other sites

your file name is OK ( {filename}.php ), maybe the issue within your code it self, you can share it here

Share this post


Link to post
Share on other sites

I did some quick testing on my WHMCS installation and was able to get the following hook function working to remove the 'Network Status' submenu item from the 'Support' menu.

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) {
   if (!is_null($primaryNavbar->getChild('Support'))) {
       $primaryNavbar->getChild('Support')->removeChild('Network Status');
   }
});

 

I simply placed this inside the /includes/hooks directory in a file called remove_network_status.php

Share this post


Link to post
Share on other sites
want to remove the 'Order Hosting' from the main homepage where it states "How can we help today?"

this one will be a template edit - six/header.tpl - remove the following...

 

                        <li>
                           <a id="btnOrderHosting" href="cart.php">
                               <i class="fa fa-hdd-o"></i>
                               <p>
                                   {$LANG.orderhosting} <span>»</span>
                               </p>
                           </a>
                       </li>

Share this post


Link to post
Share on other sites

Many thanks for the help with this one.

 

I have managed, with the code above, to remove the Network Status on the top Nav bar, thank you!

 

I am having an issue with the sidebar though. This is what I thought would have worked but only breaks the site:

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

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

 

- - - Updated - - -

 

Thanks Brian. I decided to just change the wording so it fits with what's on offer rather than hosting...thanks :-)

Share this post


Link to post
Share on other sites
I am having an issue with the sidebar though. This is what I thought would have worked but only breaks the site.

lots of the code examples in the v6 docs will do this. :roll:

 

the basic rule to follow is that you need to check if the menu/sidebar etc exists - and only if it does, can you modify it... if you try to modify something that doesn't exist, that's when you get a blank page...

 

http://forum.whmcs.com/showthread.php?104955-Using-hooks-to-change-sidebar-menus-works-on-some-pages-blank-screens-on-others&p=432506#post432506

Share this post


Link to post
Share on other sites

Thanks Brian. Nothing is working to get rid of what I wanted.

 

Very much confused as everything I am trying to remove the 'Network Status' under the 'Support' sidebar is failing. The Support Sidebar only shows under the Support>Tickets & Support>Downloads pages it seems. I have removed near enough everything else required so I will leave it be I think...it only takes to a page that says no issues so I think it'll have to do!

 

Thanks for your help :-)

Share this post


Link to post
Share on other sites

the sidebar @ Support>Tickets & Support>Downloads is a secondary sidebar and not a primary one - so you'd need to use the secondary sidebar hook...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

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

tested locally and works. :idea:

Share this post


Link to post
Share on other sites

I'm still getting issues with these menus! Arrgghhhh :roll:

 

I have changed the wording for 'Home' to 'Client Area Home' and I want to add another link that says 'Home' to link to the main website. I have looked at the adding of Primary menu items, however each time I add any code that I think would work it is breaking the site!

 

Is the issue because I am trying to use 'Home' for the name again?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines