View Full Version : html question
ofek
November 12th, 2005, 10:47 AM
well i've programed alot ... and never did a real web developing.
im used to the idea that u shouldn't write the same thing twice for that there are procedures and functions(and alot more...).
im building the html of my site and well i got a top logo and a menu to the right and some other stuff which are the same in every page.
my question is if there is anyway to write those stuff only once and include it in all the pages (without frames, iframes and those stuff)?
i guess the answer is no but i gotta be sure.
kperkins
November 12th, 2005, 10:55 AM
Use php include.
You'll have to use the .php extension (instead of .html, or .htm) for your pages, but it's worth it, so you can change your headers, footers, etc. at will, and only change one file.
code is as follows :
<? include ('/path/to/header.template'); ?>
You can mix php and regular html on a page, also. It's a very small learning curve unless you want to get real fancy.
ofek
November 12th, 2005, 11:00 AM
ty, i should have said my web gotta be in asp ... so i guess ill do it with asp(vb script) although i realy hoped there is something u can do with html but i guess there isnt.
David Marrs
November 13th, 2005, 11:01 AM
I don't know much about classic ASP, I'm afraid, but in ASP.NET you can create web user controls (.ascx extension) that you can include in aspx pages in much the same way you'd include a header.h in a C file. It may be that there's an .asc equivalent for classic ASP.
As far as HTML goes, there's nothing you can do directly with html (that I'm aware of) but obviously it's quite easy to reuse <div> tags between pages and some dedicated HTML editors allow you to create a template HTML file for a project first and then easily edit that file for each page. Of course, you can do this manually to a point as well.
kanenas.net
November 13th, 2005, 01:39 PM
Like php, you can use ASP include...
<!--#include virtual="/folder/folder/file.asp"-->
It's much easier to use templates in your site ! It helps you maintain your code and you don't have to go through many lines of code all the time.
endersshadow
November 13th, 2005, 06:15 PM
It's good to note that ASP won't let you do dynamic includes, but PHP will :)
kanenas.net
November 14th, 2005, 05:27 AM
The approach is to use a variable to hold the name of the file that you wanted to include and then pass the name of that variable to the include directive.
The main page (a template file containing the page layout and any static content) would be loaded and passed to a string variable. Then, the contents of the include file would be loaded and passed to a string variable. The variable containing the contents of the include file would be inserted into the contents of the variable containing the main page.
;)
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.