simple Body ID Function


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



Copy this code and paste it in your HTML
  1. <?php
  2. function setBodyId() {
  3. $path = $_SERVER['REQUEST_URI'];
  4.  
  5. if(!isset($bodyId)) {
  6. if(eregi(’^/about/’,$path) == 1) {
  7. $bodyId = ‘about’;
  8. } else if(eregi(’^/blog/’,$path) == 1) {
  9. $bodyId = ‘blog’;
  10. } else if(eregi(’^/contact/’,$path) == 1) {
  11. $bodyId = ‘contact’;
  12. } else if(eregi(’^/work/’,$path) == 1) {
  13. $bodyId = ‘work’;
  14. } else if(eregi(’^/play/’,$path) == 1) {
  15. $bodyId = ‘play’;
  16. } else if ($path == ”) {
  17. $bodyId = ‘home’;
  18. } else {
  19. $bodyId = ‘general’;
  20. }
  21. }
  22.  
  23. return $bodyId;
  24. }
  25.  
  26. $bodyID=setBodyId();
  27. ?>
  28.  
  29. <body id="<?=$bodyID?>">

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.