Jump to content
Tom Wilson

Add sidebar menu

Recommended Posts

Hello

I know this is possible through hooks but I'm not sure how exactly!

In the client area within the domain details page:

1488927902_Screenshot2019-08-25at11_52_28.thumb.png.43907f90ae38e422977824e9a82cf527.png

 

I want to add an option under 'Manage' which will link to another page - how do I do this?

Share this post


Link to post
Share on other sites
4 hours ago, Tom Wilson said:

I want to add an option under 'Manage' which will link to another page - how do I do this?

as a rough starting point...

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
	$DomainDetails = $primarySidebar->getChild("Domain Details Management");
	if (empty($DomainDetails)) {
		return;
	}
	$DomainDetails->addChild('new link 5', array(
                'label' => '*My Label*',
                'uri' => 'custompage.php',
                'order' => '100',
            ));
});

hL8J7f1.png

you could use Lang::trans on the label if it needs to be multilingual and you want to create the language strings for it; the 'order' value will determine where it is located on the sidebar (lower values towards the top, higher values towards the bottom); and 'uri' contains the page that you want the child to link to.

Share this post


Link to post
Share on other sites
On 25/08/2019 at 5:02 PM, brian! said:

as a rough starting point...


<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
	$DomainDetails = $primarySidebar->getChild("Domain Details Management");
	if (empty($DomainDetails)) {
		return;
	}
	$DomainDetails->addChild('new link 5', array(
                'label' => '*My Label*',
                'uri' => 'custompage.php',
                'order' => '100',
            ));
});

hL8J7f1.png

you could use Lang::trans on the label if it needs to be multilingual and you want to create the language strings for it; the 'order' value will determine where it is located on the sidebar (lower values towards the top, higher values towards the bottom); and 'uri' contains the page that you want the child to link to.

Thanks!

 

How about a page for a web hosting product too? On this one, I would like to not only add one, but remove one too, I am wanting to remove the 'Request Cancellation' and 'Upgrade/Downgrade Options'.

 

Share this post


Link to post
Share on other sites
6 minutes ago, Tom Wilson said:

How about a page for a web hosting product too? On this one, I would like to not only add one, but remove one too, I am wanting to remove the 'Request Cancellation' and 'Upgrade/Downgrade Options'.

Hello

Setup>General Settings>other

There is an option built in to disable cancellation. try and see if it works, regarding upgrade and downgrade, i cant remember...

image.png.474c65a454b5c569d1e0bc9f64cc79ff.png

Share this post


Link to post
Share on other sites
11 minutes ago, Tom Wilson said:

How about a page for a web hosting product too?

11 minutes ago, Tom Wilson said:

On this one, I would like to not only add one, but remove one too, I am wanting to remove the 'Request Cancellation' and 'Upgrade/Downgrade Options'.

$kidsToIcon = array("Upgrade/Downgrade","Cancel");
1 minute ago, zitu4life said:

regarding upgrade and downgrade, i cant remember...

it's in the product setup for each product.. setup -> product/services -> product/services -> *choose product* -> upgrades -> untick Configurable Options checkbox.

if you're wanting to remove both cancellation and config upgrades on all products, then you can use either method... if you want to remove them for specific products, then you'll need the hook.

and with regards to adding a child..

$ActionDetails->addChild('new link 6', array(
                'label' => '*My Label*',
                'uri' => 'custompage.php',
                'order' => '100',
            ));

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 and understand your posts will initially be pre-moderated