oo7ml — 2012-04-03T13:01:38-04:00 — #1
Hi, i have just finished coding a design into html / css. I have spit the code up into php includes for the HEADER, NAVIGATION and the FOOTER
I have coded my navigation so that when a tab (page) is selected from navigation it has a different style. I have declared this style in the css called .selected
Can someone help me write a simple IF statement, that will work like this:
IF the current page is 'contact.php' echo '.selected' ELSE do nothing
I was hoping to past this IF statement into the code for each tab / button so it would use the .selected class if it was on that page, thanks in advance for your help...
wonshikee — 2012-04-03T15:16:30-04:00 — #2
If the ELSE is doing nothing, you don't need to include the ELSE portion.
john_betong — 2012-04-03T23:28:12-04:00 — #3
switch( $_SERVER['REQUEST_URI'] )
case '/about.html' : $selected = 'ff0'; break;
case '/blog.html' : $selected = '0ff'; break;
case '/contact.html' : $selected = 'f0f'; break;
case '/terms.html' : $selected = 'f00'; break;
case '/subscribe.html' : $selected = '090'; break;
default : $selected = '000';
$selected = 'style="background-color:#' .$selected .'"';
<div <?php echo isset($selected) ? $selected : NULL;?> >
Beware: All Apache Versions are not the same. If on the off-chance $SERVER['REQUESTURI'] does not return the value expected then try this script:
print_r( $_SERVER );
oo7ml — 2012-04-04T05:04:51-04:00 — #4
Cool, thanks all for your help...