Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

145 users online



Dynamic Menu, Changing Link Color...

Dynamic Menu, Changing Link Color...

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 2
iamkoa

iamkoa

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

nertman

nertman

lurker
Status: Offline!

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

nertman

nertman

lurker
Status: Offline!

/////here is a sample style sheet

PHP:

<?php

<style type="text/css">
<!--
body,td,th {
    
font-familyVerdanaArialHelveticasans-serif;
    
font-size10px;
    
color#000000;
}
body {
    
background-color#FFFFFF;
    
margin-left0px;
    
margin-top0px;
    
margin-right0px;
    
margin-bottom0px;
}
{
    
font-familyVerdanaArialHelveticasans-serif;
    
font-size10px;
    
color#0099CC;
}
a:link {
    
text-decorationnone;
}
a:visited {
    
text-decorationnone;
    
color#0099CC;
}
a:hover {
    
text-decorationunderline;
    
color#CCCCCC;
}
a:active {
    
text-decorationnone;
    
color#0099CC;
}
.
pageselected,a,a:link,a:visited,a:active {
    
font-familyVerdanaArialHelveticasans-serif;
    
font-size10px;
    
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:


<?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>;
}
?>

Natural

Natural

Status: Offline!

i just create a varible for the page im on

$pageIS

then just do an if else on the class on the menu...

PHP:


&raquo; <a href="index.php"<? if ($pageIs == "index") { ?> id="pink"<?php ?>>ABOUT NITRO</a><br />
&raquo; <a href="eventmodels.php?location=Auckland&sex=female"<? if ($pageIs == "female") { ?> id="pink"<?php ?>>PROMO GIRLS</a><br />
&raquo; <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.

angelessme

angelessme

Neversidian
Status: Offline!

use a function.

___________________

angelessme, antagonising neverside members, staff and administration since 2001.

iamkoa

iamkoa

Neverside Newbie
Status: Offline!
Quote:

Originally posted by angelessme
use a function.

Code example?

___________________

http://iamkoa.net

colincameron

colincameron

Neverside Newbie
Status: Offline!

Here is an easier way to do this

http://www.alistapart.com/articles/keepingcurrent/

colincameron

colincameron

Neverside Newbie
Status: Offline!
Quote:

use a function.

i cant get it to work.. some help.!?

PHP:


<?
function homeTab()
{
    if ( 
$section=="home" 
    echo 
" id=\"current\"";
}
?>

the function is in a include and on the actual page i have

PHP:


<?
require('functions.php');
$section home;
include(
'inc/head.php');
?>

and in the head include i have this to call it

Code:


<li<? homeTab(); ?>>

it doesnt work? is there a reason why, i dont seem to be getting any errors either

colincameron

colincameron

Neverside Newbie
Status: Offline!

here is the simplified code of the stuff i posted above, can someone point out what im doing wrong

PHP:


<?

$tab 
home;

homeTab();

function 
homeTab()
{
    if (
$tab=="home")
    echo 
" id=\"currentpage\"";
}

?>

Last edited by colincameron, December 18th, 2004 03:21 PM (Edited 1 times)

prince

prince

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

Page 1 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0129 seconds.