I am working on a site and am not very JavaScript savvy. I am using a php include for a navigation bar with images. I would like the images to change if you are on the relating page. I don't want any fancy rollovers or anything, just to be able to have them switch out when on the page so that I do not have to go through each page and code in a new nav with a different image. There are just far too many pages to do that now . I was hoping that there would be someone who could give me a little advice. Please help! Thank you so much!
Sorry ... here is the code for the include: <td align="left" > <a href="start.php"><img border="0" src="home_btn.gif"></a> </td> </tr> <tr> <td align="left"><a href="search_engine.php"><img border="0" src="searchengines_btn.gif"></a></td> </tr> <tr> <td align="left"><a href="store.php"><img border="0" src="webstore_btn.gif"></a></td> </tr> <tr> <td align="left"> <a href="faq_members.php"><img border="0" src="faq_btn.gif"></a></td> </tr> <tr> <td align="left"> <a href="about_us.php"><img border="0" src="aboutus_btn.gif"></a></td> </tr> <tr> <td align="left"><a href="<?=tep_href_link(FILENAME_CONTACT_US)?>"><img border="0" src="contact_btn.gif"></a></td> </tr> </table> </td> So, for example, when the user is currently on the page "about_us.php" I would like the image to change to "aboutus_btn2" (I have already made the second images) without having to edit each and every page. I don't know how this would work but to sort of lay it out if you are on such and such page then use this image. Is that possible?
thank you Well what happens now is that it is displaying the else image regardless of what page it is and is also not working as a link. I kept the link from my original code in to see if when I clicked on the page if the image would change, but it doesn't. Is there anything I need to be editing with this: $_SERVER['PHP_SELF'] ?
OK - I'm sorry that I took so long to respond. Another issue arose that I had to fix. I don't think I was missing a bracket. I recopied the new code just in case but am having the same problem. This is what I have: <td align="left"> <?php if ($_SERVER['PHP_NAV_MEMBER'] == 'about_us.php') {echo "<img border='0' src='aboutus_btn2.gif'>";} else {echo "<img border='0' src='aboutus_btn.gif'>";} ?> </td> The issue may lie in the $_SERVER['PHP_SELF']. You said that this should be equal to the filename. I may have done that wrong. I am obviously not the best coder. The filename is nav_member.php. I'm sorry this is so hard - Thank you for your help!
I didn't read your last post until after I sent that. I think I understand and showed the example of what I had tried. I am working off an already existing module for this site that uses this sort of code: <?=tep_href_link(FILENAME_CONTACT_US)?> I have had trouble when trying to recreate these sorts of things mainly with the file name.
it just returns the text. I wasn't sure if I should be using javascript or not I just had done a search. This doesn't seem to be working though so I may just have to keep the images the same. I don't see why though. It doesn't seem like that difficult of a command.
Excuse me? I did exactly that and it "just returns the text". You do not need to respond if you feel that I am wasting your time. I didn't think it was completely necessary for me to post "echo $_SERVER['PHP_NAV_MEMEBER']" ... and every other variation I tried. I find it a bit ridiculous that you feel that you can speak that way.