Results 1 to 10 of 10
  1. #1
    #include for HTML?
    mac57's Avatar
    Member Since
    Apr 29, 2006
    Location
    St. Somewhere
    Posts
    4,560
    Specs:
    iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM
    #include for HTML?
    A noob web page coder's question:

    I am "hand coding" a new web site in HTML, which I have learned by reading the very helpful book "HTML Goodies". Being "self taught", there seem to be a few gaps in my knowledge!

    A key one is this. My web site will have numerous pages, and they will all have an identical navigation pane that allows you to move between pages. Rather than copy the HTML code for this panel over and over into each page's source, I would like to write up this page section as a separate HTML file and somehow include into each page's source, rather like the #include directive does in C/C++ source code.

    Is there a way to do this in HTML?
    My Macs: iMac 27" 3.4 GHz, Mac Pro 3.2 GHz, PowerMac G5 Quad 2.5 GHz, G4 Cube with 1.2 GHz Upgrade
    My iStuff: 64GB iPhone 5, 64GB iPad4, 30GB iPod Video, 16GB iPod Touch
    My OS': Mac OS X Lion, Mac OS X Snow Leopard, Mac OS X Tiger, Mac OS 9.2.2, openSUSE 10.3
    I was on the Mac-Forums honor roll for September 2007

  2. #2
    #include for HTML?

    Member Since
    Dec 24, 2006
    Location
    N. Ireland
    Posts
    901
    Specs:
    Mac Pro 2xQuad core 2.8GHZ
    Then you need to learn php my friend

    Code:
    <php
       @include_once('name_of_file_to_include');
    ?>

  3. #3
    #include for HTML?
    mac57's Avatar
    Member Since
    Apr 29, 2006
    Location
    St. Somewhere
    Posts
    4,560
    Specs:
    iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM
    You may be right! However, for now I will stick to my original question!

    Does anyone know how to do this in HTML?
    My Macs: iMac 27" 3.4 GHz, Mac Pro 3.2 GHz, PowerMac G5 Quad 2.5 GHz, G4 Cube with 1.2 GHz Upgrade
    My iStuff: 64GB iPhone 5, 64GB iPad4, 30GB iPod Video, 16GB iPod Touch
    My OS': Mac OS X Lion, Mac OS X Snow Leopard, Mac OS X Tiger, Mac OS 9.2.2, openSUSE 10.3
    I was on the Mac-Forums honor roll for September 2007

  4. #4
    #include for HTML?
    PowerBookG4's Avatar
    Member Since
    Jan 08, 2005
    Location
    New Jersey
    Posts
    6,188
    Specs:
    Mac Pro 8x3.0ghz 12gb ram 8800GT , MBP 2.16 2GB Ram 17 inch.
    not possible, there is no #include in HTML code. You could do it via frame sets (which are a bad design mistake) or you can make the nav bar in flash and just embed the flash file at the top of each html page.
    My Website
    Blog
    I love my hosting company!
    I was on the M-F honor roll for Febuary:2006

  5. #5
    #include for HTML?
    cazabam's Avatar
    Member Since
    Jun 06, 2006
    Posts
    1,153
    Specs:
    MacBook 2.0GHz White, 512MB RAM, 60GB HDD
    There are a few ways of doing it, the most '#include' like being SSI (Server Side Includes). This is supported by the Apache web server (that comes with OS X) but I'm not sure if it's turned on. It's certainly something to look at if you don't want to learn PHP just to use includes

  6. #6
    #include for HTML?
    xstep's Avatar
    Member Since
    Jun 25, 2005
    Location
    On the road
    Posts
    3,231
    Specs:
    2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
    If you're using straight html then you want to look into server side includes.

    Keep in mind that some hosting services turn that feature off. They suck. You should be able to do a quick test to find out. If your just using your OS X box, then you can set it up if it is turned off.

  7. #7
    #include for HTML?
    Murlyn's Avatar
    Member Since
    Jun 11, 2003
    Location
    Mount Vernon, WA
    Posts
    4,915
    Specs:
    MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
    Yep SSI, but that's not really html either. The ONLY way to do it in HTML is using iframes like was mentioned above, or frames (frameset) Both iframe and frameset's are not recommended, but it is the only answer to your question if you refuse to use a dynamic language.

  8. #8
    #include for HTML?
    mac57's Avatar
    Member Since
    Apr 29, 2006
    Location
    St. Somewhere
    Posts
    4,560
    Specs:
    iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM
    Thanks everyone. Amazing! It is hard to believe that such an obvious feature doesn't exist in HTML! I guess that this is why I didn't find it in the HTML Goodies book.

    I am guessing that any concept of macros doesn't exist either - this would be another way of achieving it.

    I guess I will just copy and paste. As an old software designer, that makes me crazy, but I guess that is my only route.
    My Macs: iMac 27" 3.4 GHz, Mac Pro 3.2 GHz, PowerMac G5 Quad 2.5 GHz, G4 Cube with 1.2 GHz Upgrade
    My iStuff: 64GB iPhone 5, 64GB iPad4, 30GB iPod Video, 16GB iPod Touch
    My OS': Mac OS X Lion, Mac OS X Snow Leopard, Mac OS X Tiger, Mac OS 9.2.2, openSUSE 10.3
    I was on the Mac-Forums honor roll for September 2007

  9. #9
    #include for HTML?
    cazabam's Avatar
    Member Since
    Jun 06, 2006
    Posts
    1,153
    Specs:
    MacBook 2.0GHz White, 512MB RAM, 60GB HDD
    Contrary to popular belief (and what many web designers might tell you), HTML isn't a programming language and so therefore wouldn't have things like macros, commands and statements to do anything. It's just a way of representing the way a document should be formatted. It's a document format, pure and simple.

  10. #10
    #include for HTML?
    Murlyn's Avatar
    Member Since
    Jun 11, 2003
    Location
    Mount Vernon, WA
    Posts
    4,915
    Specs:
    MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
    Yep, what cazabam said. It's good to make that clarification. Im a web developer, so I work with PHP and MySQL etc and sure I know HTML since it's a huge part of what I do also, but anything that is dynamic I create using PHP, html is just a markup language "Hyper Text Markup Language" Anyways good luck and you should really look into PHP it would make your life much easier especially for what you are doing

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to include recaptcha image only?
    By BrandonSkyPim in forum OS X - Operating System
    Replies: 1
    Last Post: 02-28-2012, 07:31 PM
  2. Replies: 0
    Last Post: 08-22-2011, 09:18 AM
  3. iweb to html to html newsletter?
    By skibum232 in forum Web Design and Hosting
    Replies: 1
    Last Post: 11-30-2010, 12:05 AM
  4. Opening Local HTML files - render HTML (not display as text)
    By Gator626 in forum OS X - Operating System
    Replies: 6
    Last Post: 11-01-2009, 08:00 PM
  5. What will Leopard include?
    By mshale in forum Schweb's Lounge
    Replies: 8
    Last Post: 10-01-2007, 02:37 PM

Posting Permissions

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