Jump to content

Archived

This topic is now archived and is closed to further replies.

notDeadYet

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

Recommended Posts

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

Share this post


Link to post
Share on other sites
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";

}

?>

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.