Jump to content

How to Activate a Link in Navigation ?


Wdes

Recommended Posts

Hello guys,

I search for activate the active page on the six-template

I found some old topics for sorry it's not useful and needs a manual way to activate each page separately

and in attachment an example of what I wanna

Waiting to hear from you

Thank you.

Screen Shot 2018-03-05 at 8.40.57 PM.png

Link to comment
Share on other sites

On 3/6/2018 at 20:28, twhiting9275 said:

I'm not terribly sure that's possible post 6 , though it might be.

that's covering yourself! :lol:

On 3/6/2018 at 20:28, twhiting9275 said:

Take a look at the theme documentation - If what you're after is possible it should be there.

good luck finding how to do this via the documentation. 9_9

On 3/5/2018 at 18:31, Des Team said:

I found some old topics for sorry it's not useful and needs a manual way to activate each page separately

if the old topics showed you how to change one menu item, then you know how to change many.... in fact, there are a number of ways to do it - some of which are nastily complex, but one simple way to do it would be...

<?php

# Primary Navbar Active Class
# Written by brian!

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	GLOBAL $smarty;
	$templatefile = $smarty->getVariable('templatefile');
	$filename = $smarty->getVariable('filename');
	$action = $smarty->getVariable('action');

	$filelinks = array('Store' => 'cart','Affiliates' => 'affiliates','Open Ticket' => 'submitticket','Support' => 'supporttickets');
	$templatelinks = array('Announcements' => 'announcements','Knowledgebase' => 'knowledgebase','Server Status' => 'serverstatus','Services' => 'clientareaproducts','Domains' => 'clientareadomains');
	$billinglinks = array('invoices','quotes','addfunds');
	$homelinks = array('homepage','clientareahome');
	$supportlinks = array('supportticketslist','announcements','knowledgebase','downloads','serverstatus');

	$currentfile = array_search($filename, $filelinks);
	$currentpage = array_search($templatefile, $templatelinks);

	if (!is_null($primaryNavbar->getChild($currentfile))) {
		$primaryNavbar->getChild($currentfile)
			->setClass(( ! isset($_GET['modop']) ? 'active' : ''));
	}
	elseif (!is_null($primaryNavbar->getChild($currentpage))) {
		$primaryNavbar->getChild($currentpage)
			->setClass(( ! isset($_GET['modop']) ? 'active' : ''));
	}
	elseif (in_array($action, $billinglinks) & !is_null($primaryNavbar->getChild('Billing'))) {
		$primaryNavbar->getChild('Billing')
			->setClass(( ! isset($_GET['modop']) ? 'active' : ''));
	}
	elseif (in_array($templatefile, $homelinks) & !is_null($primaryNavbar->getChild('Home'))) {
		$primaryNavbar->getChild('Home')
			->setClass(( ! isset($_GET['modop']) ? 'active' : ''));
	}	
	elseif (in_array($templatefile, $supportlinks) & !is_null($primaryNavbar->getChild('Support'))) {
		$primaryNavbar->getChild('Support')
			->setClass(( ! isset($_GET['modop']) ? 'active' : ''));
	}
});

if the structure of the navbar links made any logical sense, you could reduce this code down - but with the above method, you end up having to check filenames, template names and actions to cover all the options.

kKtsR3O.png

if you've added any custom navbar parent items, you'd need to manually add them to the hook.... and looking at the code again, I think i've missed off the contact us link.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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