Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   Web Design and Hosting (http://www.mac-forums.com/forums/web-design-hosting/)
-   -   #include for HTML? (http://www.mac-forums.com/forums/web-design-hosting/50174-include-html.html)

mac57 01-13-2007 02:35 PM

#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?

Del 01-13-2007 02:40 PM

Then you need to learn php my friend

Code:

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


mac57 01-13-2007 03:32 PM

You may be right! However, for now I will stick to my original question!

Does anyone know how to do this in HTML?

PowerBookG4 01-13-2007 03:35 PM

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.

cazabam 01-13-2007 08:05 PM

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 :)

xstep 01-13-2007 10:50 PM

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.

Murlyn 01-14-2007 01:39 AM

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.

mac57 01-14-2007 02:27 PM

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.

cazabam 01-14-2007 02:31 PM

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.

Murlyn 01-14-2007 02:58 PM

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 :)


All times are GMT -4. The time now is 12:37 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.