How to have current page selection using inludes navigation

Posted by Anders Kitson on Stack Overflow See other posts from Stack Overflow or by Anders Kitson
Published on 2010-05-13T01:27:23Z Indexed on 2010/05/13 1:34 UTC
Read the original article Hit count: 292

Filed under:
|
|

I am using php includes to limit redundancy on my pages, how can I have my navigation have the current page selected with say a certain color for the HOME button when my navigation is called from a header.php file.

If i were to say to add a "active" class to the home.php item and add a style so it looked different, that would happen across the board for all my pages, which is why I am using includes in the first place, how can I have one header.php file with my navigation, that also allows each page the ability to show the current page you are on reflected in the navigation?

This is the nav portion of the header.php file

  <ul>
 <li><a href="index.php">About Us</a></li>
 <li><a href="portfolio.php">Portfolio</a></li>
 <li><a href="news.php">News</a></li>
 <li><a href="contact.php">Contact</a></li>
    </ul>

This is the index.php file that the header.php file is included in

  <?php
   include("includes/header.php");
  ?>

 <div class="span-8" id="welcome">
  <p>Lorem ipsum</p>
 </div>

 <div class="span-16 last" id="slideshow">
  <img src="images/introImage1.png" alt="fountain">
  <img src="images/introImage2.png" alt="bench">
  <img src="images/introImage3.png" alt="bridge">
 </div>

 <?php
  include("includes/footer.php");
  ?>

© Stack Overflow or respective owner

Related posts about includes

Related posts about php