Jump to content

Adding A New Menu Item To Menu Bar


Recommended Posts

Hi @brian!

 

My Issue was resolved...Thank you so much :)

SBLHJaA.png

This resolved my problem...only thing left is - How to make these menu items open in a new tab ?

0DXyfYQ.png

<?php

use WHMCS\View\Menu\Item as MenuItem;
 
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	$client = Menu::context('client');
	$primaryNavbar->addChild('newhome',array('label' => Lang::trans('hometitle'),'uri' => 'https://my site/','order' => 1,'icon' => 'fa-home',));
	if (!$client && !is_null($primaryNavbar->getChild('Home'))) {
		$primaryNavbar->getChild('Home')->setUri('clientarea.php');
	}
});

POST - 

 

Best Wishes #StaySafe

Edited by VirtualWorldGlobal
Link to comment
Share on other sites

as you have found, that's going to be a primarynavbar hook.

https://developers.whmcs.com/hooks-reference/client-area-interface/#clientareaprimarynavbar

6 minutes ago, VirtualWorldGlobal said:

only thing left is - How to make these menu items open in a new tab ?

you set a 'target' attribute in the hook.

$primaryNavbar->getChild('Home')->setUri('clientarea.php')->setAttribute('target','_blank');
Link to comment
Share on other sites

Sorry I tried to set as below, but not working...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;
 
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    $client = Menu::context('client');
    $primaryNavbar->addChild('Sales',array('label' => Lang::trans('Sales'),'uri' => 'https://www.domain.com.com/sales/','order' => 1,'icon' => 'fa fa-shopping-cart',));
    if (!$client && !is_null($primaryNavbar->getChild('Home'))) 
    {
        $primaryNavbar->getChild('Home')->setUri('clientarea.php')->setAttribute('target','_blank');
    }
});

 

Link to comment
Share on other sites

14 minutes ago, VirtualWorldGlobal said:

Sorry I tried to set as below, but not working...

it works, but I think I assigned the target to the wrong child...

<?php

use WHMCS\View\Menu\Item as MenuItem;
 
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	$client = Menu::context('client');
	$primaryNavbar->addChild('newhome',array('label' => Lang::trans('hometitle'),'uri' => 'https://www.google.com/','order' => 1,'icon' => 'fa-home',))->setAttribute('target','_blank');
	if (!$client && !is_null($primaryNavbar->getChild('Home'))) {
		$primaryNavbar->getChild('Home')->setUri('clientarea.php');
	}
});
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