Jump to content

Edit sidebars items


Recommended Posts

Hello!

I am trying to see how I can edit and remove certain sidebar items. 

I have gone over the guides on editing the sidebar using hooks but have not found how I can hide certain items. 

I am using an external service for knowledge base, network status and announcements.

Is it possible to change the url these go to when clicked from within the client area sidebar?

I do not use the downloads feature so I would like to be able to hide that. 

Link to comment
Share on other sites

10 hours ago, justaserverguy said:

Is it possible to change the url these go to when clicked from within the client area sidebar?

yes... if you ignore the navbar parts and just focus on the sidebar part of the hook below, that can be used to change the links in that sidebar...

10 hours ago, justaserverguy said:

I do not use the downloads feature so I would like to be able to hide that. 

if you're doing that in a hook, then it's just a removeChild.

if (!is_null($secondarySidebar->getChild('Support'))) {
	$secondarySidebar->getChild('Support')->removeChild('Downloads');
}
Link to comment
Share on other sites

8 hours ago, brian! said:

yes... if you ignore the navbar parts and just focus on the sidebar part of the hook below, that can be used to change the links in that sidebar...

if you're doing that in a hook, then it's just a removeChild.


if (!is_null($secondarySidebar->getChild('Support'))) {
	$secondarySidebar->getChild('Support')->removeChild('Downloads');
}

Sorry if this is a dumb question, I am going to Includes/Hooks but there is nothing in there. Am i going to the wrong spot or do I need to create files for these inside of includes/hooks?

Link to comment
Share on other sites

2 hours ago, brian! said:

i'd need to see the code - but it's worth mentioning that you don't necessarily need them in separate files - you can put associated hooks in the same .php file and then you can keep a clearer handle on what you're changing.

Here is what I came up with. 

What is also strange is that it works when in the downloads, announcement, knowledge base and server status  pages. 

But when in the Support Tickets or Open Tickets page it pulls the default sidebar. 🤔

<?php

use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
	if (is_null($secondarySidebar->getChild('Support'))) {
		return;
	}
	if (!is_null($secondarySidebar->getChild('Support')->getChild('Announcements'))) {
		$secondarySidebar->getChild('Support')
			->getChild('Announcements')
			->setUri('https://www.blog.example.com');
	}	
	if (!is_null($secondarySidebar->getChild('Support')->getChild('Knowledgebase'))) {
		$secondarySidebar->getChild('Support')
			->getChild('Knowledgebase')
			->setUri('https://www.help.example.com');
	}	
	if (!is_null($secondarySidebar->getChild('Support'))) {
	$secondarySidebar->getChild('Support')->removeChild('Downloads');
    }
    if (!is_null($secondarySidebar->getChild('Support')->getChild('Network Status'))) {
		$secondarySidebar->getChild('Support')
			->getChild('Network Status')
			->setUri('https://www.example.statuspage.io/');
	}
});

function change_homeshortcuts_support_link_hook($vars)
{
	return "<script>document.getElementById('btnGetSupport').href = 'https://www.help.example.com';</script>";
};
add_hook("ClientAreaFooterOutput",1,"change_homeshortcuts_support_link_hook");

 

Link to comment
Share on other sites

15 hours ago, justaserverguy said:

What is also strange is that it works when in the downloads, announcement, knowledge base and server status  pages. 

But when in the Support Tickets or Open Tickets page it pulls the default sidebar.

FWIW - i'm not noticing that occurring locally when I test the hook...

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