Web Analytics Made Easy -
StatCounter How to eliminate duplicated code - CodingForum


No announcement yet.

How to eliminate duplicated code

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to eliminate duplicated code

    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.

  • #2
    It's probably easiest to use PHP include()'s for this.

    Info about PHP include()'s can be found in the PHP manual.

    // freak


    • #3
      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.


      • #4
        Thank you!

        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.