Web Design Forum: PHP Menu Include and a:active CSS - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

PHP Menu Include and a:active CSS

#1 User is offline   zach21uk 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 231
  • Joined: 22-December 08
  • Reputation: 3
  • Gender:Male
  • Location:UK
  • Experience:Web Guru
  • Area of Expertise:Designer/Coder

Posted 04 January 2010 - 12:31 PM

Hi Everyone,

I am using a included PHP menu on a website I am developing, and I need to get a:active working so that the current page is highlighted on the menu.

I found this little tutorial for doing it, however it dosent work:

http://webdevjunk.co...tive-page-link/

Does anyone have any ideas how to get this working?

Zach
0

#2 User is offline   Stardog 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 91
  • Joined: 09-April 08
  • Reputation: 1
  • Location:Edinburgh
  • Experience:Advanced
  • Area of Expertise:Web Designer

Posted 04 January 2010 - 04:55 PM

This is one way I did it years ago:

In your header.php replace your <body> tag with this:

<?php
if (!isset($body) );
print '<body '.$body.'>';
?>


Imagine this is your "homepage"

<?
$body = "id=\"homepage\"";
include("header.php");
?>

<div>Homepage content.</div>

<? include("footer.php") ?>


That will give <body id="homepage"> only when the homepage is open.

Each menu item should have a unique class:

<a href="index.php" class="homepagelink">Home</a>
<a href="about.php" class="aboutpagelink">About</a>


#homepage a.homepagelink, #aboutpage a.aboutpagelink {background:#000; color:#fff;}

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users