...

View Full Version : How to eliminate duplicated code



Robin Clark
02-10-2004, 02:35 AM
I have the following elements that are the same on each page of my website:


logo at the very top
menu that is composed of gif buttons that is just below the logo
footer that has a different logo and some text


My customer wants to use the gif buttons.

Is there any way to put this code in one file and then "include" it in all the pages? I would prefer to not duplicate the same html in each webpage.

I've looked through quite a bit of documentation and can not see how to do it, but it also seems that there is a way to do just about anything if you are very clever.

freak
02-10-2004, 03:35 AM
It's probably easiest to use PHP include()'s for this.

Info about PHP include()'s can be found in the PHP manual (http://php.net/include/).

// freak

oracleguy
02-10-2004, 04:15 AM
You can also use ASP or just plain shtml to do this. What it is, is a server side include, thats what you want to do. When the page is requested on the server, it accesses the include and put the contents into the page at that point, then it sends it to the client.

Try searching the forum for shtml, there a couple threads that have good explenations.

Robin Clark
02-11-2004, 12:04 AM
Because I'm not using any php yet, I'm going to use the shtml. This is exactly the information that I was looking for. My code will be much cleaner now.

Thank you for the great advice.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum