Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2004
    Location
    Cincinnati, OH
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 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
    New Coder
    Join Date
    Dec 2003
    Location
    California
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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.
    OracleGuy

  • #4
    New Coder
    Join Date
    Feb 2004
    Location
    Cincinnati, OH
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •