Jump to content

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


notDeadYet

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.