php include - navigation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oodya
Forum Newbie
Posts: 5
Joined: Sun Jun 14, 2009 7:45 am

php include - navigation

Post by oodya »

Hi,

I am trying to implement the php include function on my website. One problem that I am coming across, is that for the different pages, the section that the person is on will be a different colour (e.g. if someone clicks on the 'Gallery' page, then that button will be grey and the rest will be Orange. I have got a page called 'pages.php'. This is the page where all of my navigation links are stored. Currently this is a bit of the coding:

<li><a href="gallery.php" class=" active"><span><span>Gallery</span></span></a></li>

It is the class="active" bit that makes the button grey. How can I amend the php so that it changes depending on which page the person is on? e.g. if someone clicks on the 'About Us' page, how would I tell it to not use it for the gallery.php and to use it for the aboutus.php?

Thanks.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Re: php include - navigation

Post by miro_igov »

You can read the filename of the current page in $_SERVER['SCRIPT_NAME']; basename() may be of interest.
oodya
Forum Newbie
Posts: 5
Joined: Sun Jun 14, 2009 7:45 am

Re: php include - navigation

Post by oodya »

Hi,

Is that something I am meant to be looking for? or is that a script that I need to use. Sorry, but haven't done this before.

Thanks,
Post Reply