Jump to content

Moving some Menu Items to the right?


Recommended Posts

Basically my top navigation looks like this currently:

menuhelp.thumb.png.97cebf19df9020299c0655cbcefcbab7.png

 

And I'd like to move "Network Status" and "Contact Us" to the right side next to the account drop down. So the right looks something like: Contact Us | Network Status | Account ^

 

I can see the location of this text in header.tpl here:

 

                <ul class="nav navbar-nav navbar-right">

                    {include file="$template/includes/navbar.tpl" navbar=$secondaryNavbar}

                </ul>

But if possible, I'm wondering if I can do this by creating a hook? I'm trying to avoid editing .tpl files and couldn't figure out a hook that would do this properly. :(

 

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...
On 05/05/2019 at 08:57, Eclipsed830 said:

And I'd like to move "Network Status" and "Contact Us" to the right side next to the account drop down. So the right looks something like: Contact Us | Network Status | Account ^

from a technical point of view, you can't "move" them - you delete them from the primary navbar (left) and recreate them in the secondary navbar (right).

On 05/05/2019 at 08:57, Eclipsed830 said:

But if possible, I'm wondering if I can do this by creating a hook? I'm trying to avoid editing .tpl files and couldn't figure out a hook that would do this properly. 😞

the easiest way would be with a hook - you could do it in a template if you really had to, but it's unnecessary.

<?php

# Move Navbar Menu Items Hook
# Written by brian!

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	$client = Menu::context('client');
	if (is_null($client) &&  !is_null($primaryNavbar->getChild('Network Status'))) {
			$primaryNavbar->removeChild('Network Status');
	}
	if (is_null($client) &&  !is_null($primaryNavbar->getChild('Contact Us'))) {
			$primaryNavbar->removeChild('Contact Us');
	}
});

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{
	$client = Menu::context('client');
	if (is_null($client)) {
		$secondaryNavbar->addChild('Contact')->setLabel(Lang::trans('contactus'))->setUri('contact.php')->setOrder(10);
		$secondaryNavbar->addChild('Network')->setLabel(Lang::trans('networkstatustitle'))->setUri('serverstatus.php')->setOrder(20);
	}
});

so first half removes the current links from the primary navbar; second half adds them to the secondary navbar... i'm also assuming that this is not for loggedin clients (who won't have links to contact.php anyway) - so only those who have not logged in will see these changes.

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