Global Navigation With Active Selector (PHP)
Instead of repeating the navigation bar code in every page I want to write a single snippet of PHP code for the navigation menu bar and include that file in the relevant pages. My
Solution 1:
Check if the current script file name is part of the url that is being displayed in the navigation. If so, then assign active
class to it.
foreach($items as $item) {
if(stristr($item['url'],__FILE__)===FALSE)
{
$html .= "<li><a href='{$item['url']}' ><span><B>{$item['text']}</B></span> </a></li>";
}
else
{
$html .= "<li class='active'><a href='{$item['url']}' ><span><B>{$item['text']}</B></span> </a></li>";
}
}
Post a Comment for "Global Navigation With Active Selector (PHP)"