ThePlatoon.com
August 20, 2008, 11:43:16 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: WELCOME! As you can see we have changed forum systems, for good I hope.
 
  Home   Forum   Help Search Calendar Login Register  
  Shop Gallery  
Pages: [1]   Go Down
  Print  
Author Topic: HTML or PHP?  (Read 369 times)
0 Members and 1 Guest are viewing this topic.
Lazerblade
Sr. Member
****

Rep: 1
Offline Offline

Posts: 610
1268.50 credits

View Inventory
Send Money to Lazerblade

lazerblade@hotmail.com lazerblade01@yahoo.com
View Profile WWW
« on: April 04, 2008, 04:25:30 PM »

OK, this one may be difficult, but hopefully someone knows of a trick.

I have a multi-page site split up into headers and footers. I really want to maintain the separation as is in case more pages get added later. Of course I'll have to modify the header if I do add pages later, but I'd rather modify the code for the header and add a single page than modify all of the pages.

Currently, I have a header.php and header_menu.php. I also have the individual pages (index.php, menu.php, main_courses.php, beverages.php, etc...), and a footer.php page.

Is there a way I can have an image in header_menu.php swap from the stock image to a highlighted version (beverages.png swaps to beverages_lit.png) only if the page shown is beverages.php?

What I mean is, is there a relatively easy way to implement some code in the header_menu.php page that can check to see which page it is on and act accordingly? I understand php to an extent, but consider myself to be a beginner for the most part. I also understand HTML and XML to an extent but again- I'm no expert.


Code: "<? include 'header_menu.php'; ?>

<!-- Content here for each page -->

<? include 'footer.php'; ?>"

I can copy/paste the code as needed if it will help.
Logged



Shrap. You've left us, but not without impacting our lives.
farmboy
4:31 mile
Sr. Member
****

Rep: 9
Offline Offline

Posts: 858
3041.50 credits

View Inventory
Send Money to farmboy


View Profile
« Reply #1 on: April 04, 2008, 06:25:36 PM »

I think I can come up with some javascript code that should do what you want within the html, but I'll have to dig up some old source code for the syntax.  It should be really short, like 5 lines.
Logged

Zazoo
Administrator
Hero Member
*****

Rep: 13
Offline Offline

Posts: 1320
1589.50 credits

View Inventory
Send Money to Zazoo

View Profile WWW
« Reply #2 on: April 04, 2008, 09:54:55 PM »

If you're using the include command to add the the menu to each content page then you can just have php at the beginning of the content page that sets an ID variable (e.g. <?PHP $currentpage="BEVERAGES">, there are even commands in PHP that will return the name of the current page automatically -- like $_SERVER[’SCRIPT_NAME’]). Then have code in the header_menu.php file that checks the value of $currentpage and sets the appropriate highlight image.

~Mike
Logged

Lazerblade
Sr. Member
****

Rep: 1
Offline Offline

Posts: 610
1268.50 credits

View Inventory
Send Money to Lazerblade

lazerblade@hotmail.com lazerblade01@yahoo.com
View Profile WWW
« Reply #3 on: April 08, 2008, 11:20:12 PM »

Thanks Mike! That was so obvious and yet I couldn't even see it. Simple to implement too. Sweet!

Of course now you know I'll be coming to you for future answers.
Logged



Shrap. You've left us, but not without impacting our lives.
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC
SMF Theme © Gaia
Valid XHTML 1.0! Valid CSS!