Jump to content

Trying to remove a menu item from my primary navbar


Recommended Posts

Hello, I am trying to remove the menu items such as "Announcements" and "Knowledgebase" from my navbar. I don't use WHMCS for the front of my site and I basically give it to my customers so I can bill them (therefore I want to disable as much unnecessary stuff as possible).

 

I cannot see anywhere to do this in the admin panel, and searching on Google found solutions to this issue which involve hooks. I have tried to implement these in a custom template under includes/hook but it doesn't seem to work.

 

I don't know if the community posts I looked at were just out dated and the solution has changed, or if I am doing something wrong. So I thought I would create an account and ask myself.

 

Thanks for any help!

Link to comment
Share on other sites

  • WHMCS Technical Analyst II

Hi @Mopzilla

You can remove a nav menu item as follows:

<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
        $primaryNavbar = Menu::primaryNavbar();
        $primaryNavbar->removeChild('Announcements');
        $primaryNavbar->removeChild('Knowledgebase');
    });
    
Link to comment
Share on other sites

That hasn't worked, I am wondering if I have this file in the correct place, or maybe I need to reset my WHMCS installations cache so it updates?

I am placing that in a file named "navbar.php" within templatename/includes/hook(s)/navbar.php

I tried the word "hook" and "hooks" with no success.

Link to comment
Share on other sites

two separate hooks - really ? 🙄

On 23/11/2020 at 12:25, Mopzilla said:

I cannot see anywhere to do this in the admin panel, and searching on Google found solutions to this issue which involve hooks. I have tried to implement these in a custom template under includes/hook but it doesn't seem to work.

they would go in the /includes/hooks folder of your WHMCS install, not within the templates folder.

additionally, you can hide them using CSS in /css/custom.css if you wanted to.

#Primary_Navbar-Knowledgebase,
#Primary_Navbar-Announcements
{ display: none; }

eOPGGGR.png

bear in mind that if you're using Six (or a variant of it), to keep a copy of the custom.css file as it may get overwritten by the updater (I don't believe this will apply when you're using the '21' theme in v8.1).

also, the hook and CSS posted above only deal with the navbar links when a client is not logged in - when they are logged in (and if they have access to the client area), then there will be different links available (navbar and sidebar) - again, to remove/hide them, you would use hooks or CSS.

On 23/11/2020 at 12:25, Mopzilla said:

I cannot see anywhere to do this in the admin panel

they never included a menu manager when they added the Six template over five years ago - to manage the menu, you would a) need to use hooks, b) buy a third-party menu manager addon, c) check for existing hooks in these forums (virtually anything that you want to do will have been done and posted, or could be modified for a situation), or d) employ a developer to fix the menu...

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