Quote:
Originally Posted by yilmaz
Change
PHP Code:
<if condition="(THIS_SCRIPT=='index')"> active</if>">Home</a>
To
PHP Code:
<vb:if condition="(THIS_SCRIPT=='index')"> active</vb:if>">Home</a>
|
no no no lol, I'm sorry if I wasn't clear its not about vb3 or vb4. It's about coding in general. I'm wondering if there is a better approach to detecting which page I am on, rather than having to use an if condition for each link.
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");
Which I'm thinking will be way better than a bunch of if conditions. it would turn that top piece of code into:
HTML Code:
<div class="navLink">
<a href="index.php" class="active">Home</a> //We are on index so jQuery added class="active"
<a href="page.php">Page</a>
<a href="showthread.php">Threads</a>
</div>
Which is much easier to work with rather than having a bunch of ifs
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.