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,
Active navigation pages
Moderator: General Moderators
Re: Active navigation pages
When you post code in the forums, remember to use BBCode tags.
or [/code]
I am having difficulty visualizing how your pages are related to each other. Are all of the files in the same directory? Would you be able to post all of the pages (include only the relevant HTML, PHP, and CSS)?
Edit: This post was recovered from search engine cache.
Code: Select all
[code=php]Code: Select all
I am having difficulty visualizing how your pages are related to each other. Are all of the files in the same directory? Would you be able to post all of the pages (include only the relevant HTML, PHP, and CSS)?
Edit: This post was recovered from search engine cache.
Last edited by McInfo on Wed Jun 16, 2010 12:53 pm, edited 1 time in total.
Re: Active navigation pages
First step would be to link the CSS file to your page...
Code: Select all
<link type="text/css" rel="stylesheet" href="style.css">