Click to See Complete Forum and Search --> : help with menu idea


roondog
03-12-2007, 04:30 AM
I'm very new to PHP and I want to set up a menu as a PHP include. This seems very straight forward in itself but I would like the link to the current page to be styled differently to the others. I think I need to use an if statement but not sure what to use as the variables etc. Is this actually possible?

pruneytoes
03-12-2007, 05:36 PM
I think what you mean is to have the button / link to the current paage highlighted to show you are on that page?
If so, you could use something like this:
<?php
$highlightedlink="1";
include "/*relative path to menu file*/";
?>
then the menu file:
<a href="somewhere1"><div class="<?php if($_GLOBALS['highlightedlink'] == 1) {
echo "link_1";
} ?>">Link 1</div></a>
<a href="somewhere2"><div class="<?php if($_GLOBALS['highlightedlink'] == 2) {
echo "link_2";
} ?>">Link 2</div></a>
/*etc etc for all your links*/

and then you could make a css file containing all the formatting for the classes link_1, link_2, etc.