Hi,

Currently what I am trying to do, is on my website, if someone is on a certain page, the button for that changes to a different colour (e.g. if someone clicks on "About Us", then when they go into the page, the rest of the buttons stay one colour and the About Us is a different colour. I currently have the following pages on my site:

The CSS, a page called "pages.php" (which has all the navigation buttons on) and the actual site contents (contactus.php, aboutus.php, gallery.php) etc. All the pages with the site contents have the include function, to include pages.php. Before I had the pages.php file, I used a command like

<a href="#" class=" active"><span><span>Home</span></span></a>

This meant that when the homepage.php was clicked on, the button would change colour (when the user enters the page). Since creating the extra pages.php page, I am unable to do this. I have been given some guidance to add something like the following to the pages.php:

<ul class="artmenu">

                   <?

$x = "";
if ($_SERVER['SCRIPT_NAME'] == "categories.php") {
$x = "active";
}
?>
<li><a href="categories.php" class=" <? echo $x; ?>"><span><span>Gallery</span></span></a></li>
</ul>

But I am unable to get this to work. The main reason for this is because I think there is no link from the pages.php file to the CSS. Can someone assist please?

Thanks,

    in theory the above is correct, are you sure $_SERVER['SCRIPT_NAME'] value is what you expect?

      Write a Reply...