Posted By

grazz on 04/25/09


php include navigation active

Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


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']);
  4. // In the navigation page that gets included:<br />
  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.