Posted By

grazz on 04/25/09


Tagged

php include navigation active


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

jfherring
achilles283


Active links in included navigation


 / Published in: PHP
 

This is a snippet to assign an active class to active links when the navigation is included in a php file.

  1. // At the top of the page that includes the navigation:
  2. $page = basename($_SERVER['SCRIPT_NAME']);
  3.  
  4. // In the navigation page that gets included:<br />
  5.  
  6. // Add in the <a> tag after the href attribute:
  7. class="<?php if ($page == example.php) { echo "active"; }; ?>"

Report this snippet  

You need to login to post a comment.