Posted By

jakepaint on 08/08/07


Tagged

css menu php style navigation


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

basicmagic
hudge


change style based on current page


 / Published in: PHP
 

URL: http://www.mainepca.org/lewiston/

Change the css id by php two different ways: by pagename or by filename

  1. <?php
  2. function navigation($currentpage) {
  3. $currentFile = $_SERVER["PHP_SELF"];
  4. $parts = Explode('/', $currentFile);
  5. $parts = $parts[count($parts) - 1];
  6. if ($parts == $currentpage) {
  7. echo ' id="currentpage" ';
  8. }
  9. }
  10.  
  11. function navigationbyname($currentpage) {
  12. global $pagename; //the page name assigned at the top of each page
  13. if ($pagename == $currentpage) {
  14. echo ' id="currentpage" ';
  15. }
  16. }
  17. ?>
  18. ***************
  19. <a href="index.php"<?php navigationbyname('Home'); ?>>Home</a>
  20. <a href="vision.php"<?php navigation('vision.php'); ?>>why we are here</a>

Report this snippet  

You need to login to post a comment.