Simple PHP Navigation


/ Published in: PHP
Save to your folder(s)

Very simple navigation. Style the id using CSS. Allows you to highlight the current page with CSS.


Copy this code and paste it in your HTML
  1. //Place this in an include
  2. <ul>
  3. <li><a href="../index.php" <?php if($thisPage == 'home') echo 'id="here"';?> >Home</a></li>
  4. <li><a href="../page1/index.php" <?php if($thisPage == 'page1') echo 'id="here"';?> >Page 1</a></li>
  5. <li><a href="../page2/index.php" <?php if($thisPage == 'page2') echo 'id="here"';?> >Page 2</a></li>
  6. <li><a href="../page3/index.php" <?php if($thisPage == 'page3') echo 'id="here"';?> >Page 3</a></li>
  7. </ul>
  8.  
  9. //This php goes inside each page, notice the variable
  10. <?php
  11. $thisPage = 'home';
  12. include('includes/navigation.inc.php');
  13. ?>

URL: http://alistapart.com/articles/keepingcurrent/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.