![]() |
[General Development] Highlighting active page in a navbar?
When it comes to highlighting the active page in a navbar I find myself using if conditions, just what I've grown accustomed to.
Example: (may not be perfect, just going from the top of my head) HTML Code:
<a href="" class="class<if condition="(THIS_SCRIPT=='index')"> active</if>">Home</a> I'm asking here rather than on stack because we are vBulletin users, and a lot of stack members tend to have issues with vb lol, and maybe vb has a whole different way of detecting the current page. |
Change
PHP Code:
PHP Code:
|
Quote:
|
Quote:
I got to thinking a jQuery solution, I may add classes based on links. It would look something like: Code:
$(".navLink a[href*='" + location.pathname + "']").addClass("active"); HTML Code:
<div class="navLink"> as for the link we want styled if its not the current page, add its own class to it, and tell jQuery to remove it if it is the current page. |
Quote:
|
It was more a coding in general type of question, maybe should have posted in private coders, but i feel this section gets the most viewers lol.
It's something that could be applied too ANY vb version though. |
Quote:
Note: Maybe you know, you should always specify the name of that file first in the custom php page. custom.php PHP Code:
|
so using if conditions is the way you would do? It just felt like too much, and I got to thinking of alternative ways lol
|
All times are GMT. The time now is 06:57 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|