Jump to content

Menu Item Removal


Cowboy

Recommended Posts

A coupe of years ago I posted this thread and got some help about how to add and remove items from the menu using hooks. 

It works, to a degree, but I can't seem to remove the Store and News links from the navigation. The hook below is what I have created: 

<?php

use WHMCS\View\Menu\Item as MenuItem;

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

It removes the Knowledgebase and Network Status links, but not the News. Is my hook wrong? 

I can live with the store item being in there, but ideally I would like to remove all the menu items and add my own with custom links as I am using WordPress to supplement the site and have managed to get Avada theme to emulate the header of WHMCS (mostly). 

Any help with this will be appreciated. 

Link to comment
Share on other sites

with regards to store, you can use the IF statement from the hook below...

1 hour ago, Cowboy said:

It removes the Knowledgebase and Network Status links, but not the News. Is my hook wrong? 

how sure are you that 'News' is actually called 'News' ? maybe you've changed its label with Language Overrides or a hook, but from your description, it sounds as though you're talking about the  'Announcements' page... if so, then change 'News' to 'Announcements' in your hook and see if that works.

1 hour ago, Cowboy said:

I can live with the store item being in there, but ideally I would like to remove all the menu items and add my own with custom links as I am using WordPress to supplement the site and have managed to get Avada theme to emulate the header of WHMCS (mostly). 

you could loop though the navbar(s) children and remove them in a foreach loop without the need to specify each individually.

Link to comment
Share on other sites

Ah, of course - that was it. I had renamed it loooong ago. 🙂 Thank you very much for the tip. 

1 hour ago, brian! said:

you could loop though the navbar(s) children and remove them in a foreach loop without the need to specify each individually.

That sounds a little above my current level of understanding of WHMCS. Can you give a little more detail? 

Link to comment
Share on other sites

having a verify difficult time even finding the correct tpl file to edit the menu lol.  from the documentation i'm reading i see navbar.tpl and header.tpl...neither of which have a hint of anything menu related in them.  i got to them in the templates/theme/includes directory.  what am i missing here? Thanks.

Link to comment
Share on other sites

On 07/05/2020 at 03:22, Greysoul said:

having a verify difficult time even finding the correct tpl file to edit the menu lol.

that's because the menus are no longer edited in the template - you can do it there if you have to, but it's so messy, I wouldn't even bother.

On 07/05/2020 at 03:22, Greysoul said:

from the documentation i'm reading i see navbar.tpl and header.tpl...neither of which have a hint of anything menu related in them.

navbar would - it's used to display the menu.

On 07/05/2020 at 03:22, Greysoul said:

i got to them in the templates/theme/includes directory.  what am i missing here?

the fact that you will have to use hooks to edit the menus.

if you don't want to deal with hooks, then you can always buy the Advanced Menu Manager, which creates a CSS version of the menu and allows you to easily edit it.... I think there are a couple of similar products in Marketplace too.

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