Jump to content


Photo

page detection so nav link stay in the "on" state on that page


  • Please log in to reply
2 replies to this topic

#1 notDeadYet

notDeadYet
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 05 October 2006 - 12:09 AM

Hello,

I'm a n00bie with php. This is the end result that I want:  I want my navigation links to be able to detect what page it is on and then leave that link in the "on" state - oh the home page, the "home" link is in the on state. I want to do this so I only need one nav text file to use as an include.

I was thinking on using switch statements (did I say that right?). I'm using images for the links, so I would need it to swap images. I'm on the edge of figuring ou how to do that but I need a push!

If I use this code:
[pre]<?php

?pageName = "faq"; // name of this page

switch ($link) {
case "icf";
echo = "images/icf_on.jpg";
break;
case "products";
echo = "images/products_on.jpg";
break;
case "events":
echo = "images/events_on.jpg";
break;
case "projects":
echo = "images/projects_on.jpg";
break;
case "faq":
echo = "images/faq_on.jpg";
break;

}

?>[/pre]
then, I'm not sure what to put for the echo. What would the html nav file use to determine the correct link to leave "on"?

Like I said, I'm new at this and I've gotten myself confused. I know someone can help me - thank!

Sherill

#2 phporcaffeine

phporcaffeine
  • Members
  • PipPipPip
  • Advanced Member
  • 361 posts
  • LocationOhio, USA

Posted 05 October 2006 - 12:31 AM

I'm not all that sure what you are looking for but try something like this:

<?php

if ($_GET['detectable_variable'] == "Some Value") {

    echo "the 'on' state link text";

}

else {

    echo "the 'off' state link text";

}

?>
Thanks,

Ryan Huff
President & Founder, MyCodeTree
support@mycodetree.com | http://mycodetree.com

#3 notDeadYet

notDeadYet
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 05 October 2006 - 12:53 AM

My thinking was to make the variable the page name, define that at the top and then the case statements determine what is supposed to happen for that particular page. I'm not sure what the switch variable would be..... switch (?pageName) ?

What would the echo statments look like if the links are images, no text at all, and then how do I call that in the html nav file?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users