What I'm trying to do is probably really simple, so I'll be having a stupid moment no doubt.
On my buttons I have a pink background when I hover over the button. This works fine. What i also need to do is for the button background to remain pink if I am on that page. The header file is called from an 'includes' folder BTW so I will not be able to assign a seperate class to it for each page I am on.
<?php
/*
example of '$links';
protected $links = array('home' => 'index.php',
'about' => 'about.php);
*/
function admin_navigation() {
foreach ($this->links as $key => $value) {
$lengthOfFileName = strlen($value);
$extractedName = substr($_SERVER['PHP_SELF'], -($lengthOfFileName));
if ($extractedName == $value) {
echo "<span class=\"inactive\">$key</span>";
}
else {
echo "<a href=\"$value\" title=\"$key\">$key</a>";
}
}
}?>
'$links' is an associative array that contains your pages and the pagenames. When the navigation is created, the script checks the name of the page (physical name of the page i.e index, about). If it matches it echo's a <span> tag with a value of 'inactive'. The css then 'dresses' up that link as something else so you can have it appear different from the other links.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering