Forum Moderators: coopster
<?
$path = $_SERVER['PHP_SELF'];
$page = basename($path);
$page = basename($path, '.php');
?>
<ul id="nav">
<li><a href="about.php" <? if($page == 'about') print ' class="current"'; ?></a></li>
</ul>
The IF statement prints a 'class="current"' into the link allowing the CSS to display my style for a current page - in turn, highlighting.
My problem is I need a new code. My website has sections now (folders), these sections make up the top navigation of my site (these are links to inside each folder). These sections are: About, Services, Work, Articles. I've organized my file structure the same, so I have 4 different folders labeled: About, Services, Work, Articles.
Each folder contains the PHP files for that section. Example:
Folder "about"
* company.php
* services.php
* history.php
The files links would look like this:
* about/company.php
* about/services.php
* about/history.php
Now, remember the top navigation, these are all links to different sections / folders. Is it possible to have these links stay highlighted depending on the folder I'm in? For instance: "about/company.php" <--- this link would be highlighted using the codes above, but the top navigation link would also be highlighted indicating that user was in the "about section".
What is the code for this?
[edited by: Nealreal at 5:19 pm (utc) on Mar. 3, 2009]
If you attempt to write the code and have trouble, post what you've tried so far and how it isn't working, and I know you will get help from myself or from the many helpful WebmasterWorld members who frequent this forum.