expandmind Posted April 29, 2010 Share Posted April 29, 2010 Hello, header.tpl >> In my navigation I have a list of pages: <ul id="mainmenu"> <li class="active"><a href="/home">Home</a></li> <li><a href="/page1">/Page2</a></li> <li><a href="/page/page2">Page2</a></li> </ul> How do I go about creating something that automatically changes the active page to have the class 'active' assigned to it? - Active links on my main menu. Thank you in advance. 0 Quote Link to comment Share on other sites More sharing options...
EricHamby Posted May 2, 2010 Share Posted May 2, 2010 Id like to know this one also. 0 Quote Link to comment Share on other sites More sharing options...
expandmind Posted May 2, 2010 Author Share Posted May 2, 2010 Id like to know this one also. hi, from the WHMCS support they told me, " You can see this on the Creating Pages module in the wiki: http://wiki.whmcs.com/Creating_Pages it is the $breadcrumbnav you need to set " Any idea how to do this with my example? 0 Quote Link to comment Share on other sites More sharing options...
simplexwebs Posted May 4, 2010 Share Posted May 4, 2010 We did this on our whmcs based site (http://www.simplexwebs.com) using smarty {if} statements and a bit of php. In each of the pages, we created a smarty variable called 'category' and assigned it the page name eg. $category = "hosting"; initialiseClientArea($pagetitle,$pageicon,$breadcrumbnav); $smartyvalues["category"] = $category; or $category = "aboutus"; initialiseClientArea($pagetitle,$pageicon,$breadcrumbnav); $smartyvalues["category"] = $category; then in the header.tpl we used: {if $category eq NULL} {php} $basename=pathinfo($_SERVER["PHP_SELF"]); $basename=$basename["basename"]; if ($basename=="index.php") { echo(' SHOW HOMEPAGE ACTIVE '); } else { echo(' SHOW ACTIVE WHMCS PAGES E.G SUPPORT, KNOWLEDGEBASE ETC. '); {/php} {elseif $category eq sharedhosting} CODE FOR NAV WITH SHARED HOSTING ACTIVE {/if} Just repeating the elseif for however many categories you have. This might seem a little long winded, but its the only decent option I found that works. 0 Quote Link to comment Share on other sites More sharing options...
expandmind Posted May 4, 2010 Author Share Posted May 4, 2010 Hello, I think there is a much easier way to this, with help from Mat WHMCS Support - Thank you, " The variable $filename contains the current page the user is on so in the template files, you could for example do something like this: <li{if $filename eq "announcements"} class="active"{/if}><a href="announcements.php">Announcements</a></li> And with that, if the page was announcements, that menu option would be active. You can do the same for other page names aswell." regards, Alex 0 Quote Link to comment Share on other sites More sharing options...
EricHamby Posted May 5, 2010 Share Posted May 5, 2010 (edited) Hello, I think there is a much easier way to this, with help from Mat WHMCS Support - Thank you, " The variable $filename contains the current page the user is on so in the template files, you could for example do something like this: <li{if $filename eq "announcements"} class="active"{/if}><a href="announcements.php">Announcements</a></li> And with that, if the page was announcements, that menu option would be active. You can do the same for other page names aswell." regards, Alex I see a issue with this however, some pages have the same filename, but different actions. So while this is easier... its also useless. Edited May 5, 2010 by EricHamby 0 Quote Link to comment Share on other sites More sharing options...
expandmind Posted May 5, 2010 Author Share Posted May 5, 2010 I see a issue with this however, some pages have the same filename, but different actions. So while this is easier... its also useless. using {if $filename eq "clientarea" and $smarty.get.action eq "details"} you can show as active the pages with same filename, but different actions.. Thank you, Alex 0 Quote Link to comment Share on other sites More sharing options...
EricHamby Posted May 5, 2010 Share Posted May 5, 2010 now that works perfect http://since83.com/clients/ 0 Quote Link to comment Share on other sites More sharing options...
simplexwebs Posted May 7, 2010 Share Posted May 7, 2010 Ah, Thats certainly a lot easier than my method. Thanks for this Alex. Regards, Rob 0 Quote Link to comment Share on other sites More sharing options...
expandmind Posted May 11, 2010 Author Share Posted May 11, 2010 you welcome! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.