/ Published in: PHP
URL: http://alistapart.com/articles/keepingcurrent/
Very simple navigation. Style the id using CSS. Allows you to highlight the current page with CSS.
Expand |
Embed | Plain Text
//Place this in an include <ul> <li><a href="../page1/index.php" <?php if($thisPage == 'page1') echo 'id="here"';?> >Page 1</a></li> <li><a href="../page2/index.php" <?php if($thisPage == 'page2') echo 'id="here"';?> >Page 2</a></li> <li><a href="../page3/index.php" <?php if($thisPage == 'page3') echo 'id="here"';?> >Page 3</a></li> </ul> //This php goes inside each page, notice the variable <?php $thisPage = 'home'; include('includes/navigation.inc.php'); ?>
Comments
Subscribe to comments
You need to login to post a comment.

An easier and less cumbersome method is to do it all with CSS. With the code below, all you have to do is switch out the class using PHP (no messy if statements required within the HTML).