
December 12th, 2004
09:12 AM
Neverside Newbie
Status: Offline!
Dynamic Menu, Changing Link Color...
Hi guys,
I came across this site (as well as thousands of others) and have always wanted to know how to use PHP in order to accomplish what the site (http://www.autonomadic.com/) has done.
Notice the menu options change color depending upon where you're located within the site. Clicking "bio" will bring you to the bio page AND change the menu to highlight "bio" as white.
Also notice the URL at the bottom right changes to display exactly where you are located on the site. (The index page displays: http : / / www.autonomadic.com / index.html)
How are both these things (the menu and the URL) done using PHP?
Thank you in advance for all your help!
___________________
http://iamkoa.net

December 12th, 2004
05:30 PM
i don't think they use php for their links to be like that cause they have a different index page for each section, but you can use links like that in php just make a if bios page then display the bios set of links and have css to display the bios link as white i can maybe give you an example of the code later if you can't fingure it out yourself
set up in your css a "selected" stlye for the link
in the nav area make some if else statments or switch statments linda like you would do with the content
other then doing it the above odd way you can just have a seperate index.html page for each page which is a pain in the add if you want to add more links or something to all the pages

December 12th, 2004
05:45 PM

/////here is a sample style sheet
<?php
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
}
body {
background-color: #FFFFFF;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
a {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #0099CC;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #0099CC;
}
a:hover {
text-decoration: underline;
color: #CCCCCC;
}
a:active {
text-decoration: none;
color: #0099CC;
}
.pageselected,a,a:link,a:visited,a:active {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #006633;
}
-->
</style>
?>
////here is a sample of the code :/ i don't even know if below will work and to have it include use index.php?nav=main01 or whatever page nav you want displayed
<?php
switch($_GET['nav'])
{
case 'main2':
print <a href="#">main01</a><br>;
print <a href="#" class="pageselected">main02</a><br>;
print <a href="#">main03</a><br>;
break;
case 'main3':
print <a href="#">main01</a><br>;
print <a href="#">main02</a><br>;
print <a href="#" class="pageselected">main03</a><br>;
break;
default:
print <a href="#" class="pageselected">main01</a><br>;
print <a href="#">main02</a><br>;
print <a href="#">main03</a><br>;
}
?>

December 12th, 2004
07:41 PM
i just create a varible for the page im on
$pageIS
then just do an if else on the class on the menu...
» <a href="index.php"<? if ($pageIs == "index") { ?> id="pink"<?php } ?>>ABOUT NITRO</a><br />
» <a href="eventmodels.php?location=Auckland&sex=female"<? if ($pageIs == "female") { ?> id="pink"<?php } ?>>PROMO GIRLS</a><br />
» <a href="eventmodels.php?location=Auckland&sex=male"<? if ($pageIs == "male") { ?> id="pink"<?php } ?>>PROMO GUYS</a><br />
theres prob a better way to do it but this works for me.

December 12th, 2004
09:48 PM
Neversidian
Status: Offline!
use a function.
___________________
angelessme, antagonising neverside members, staff and administration since 2001.

December 17th, 2004
05:35 AM
Neverside Newbie
Status: Offline!

December 17th, 2004
07:45 AM
Neverside Newbie
Status: Offline!
i cant get it to work.. some help.!?
<?
function homeTab()
{
if ( $section=="home" )
echo " id=\"current\"";
}
?>
the function is in a include and on the actual page i have
<?
require('functions.php');
$section = home;
include('inc/head.php');
?>
and in the head include i have this to call it
it doesnt work? is there a reason why, i dont seem to be getting any errors either

December 18th, 2004
03:16 PM
Neverside Newbie
Status: Offline!
here is the simplified code of the stuff i posted above, can someone point out what im doing wrong
<?
$tab = home;
homeTab();
function homeTab()
{
if ($tab=="home")
echo " id=\"currentpage\"";
}
?>
Last edited by colincameron, December 18th, 2004 03:21 PM (Edited 1 times)

December 18th, 2004
03:44 PM
Internet junkie :)
Status: Offline!
Not sure if this page will help or be worst - but it has a couple of examples to change color of the current page
http://www.maketemplate.com/menu/
___________________
Razorback Fan
http://www.ibdprince.com
Simple PHP CSS tutorials