|
|
|
|
![]() ![]() |
Sep 10 2004, 03:16 PM
Post
#1
|
|
|
Member [ Level 2 ] Group: Members Posts: 55 Joined: 7-September 04 Member No.: 351 |
Hello All,
I am very new to this site, and even to web development. I was given a task to make a site using html(and anything I am intrested in). This site would have a common template along all the pages in it. Now what I want is, Is there any way to define a template using HTML. If yes how? If no, what is the other easiest option for it. I dont like to code the sanme stuff in all the pages. Is there any way of data reusability. I thought of some other way, like making a page with the template(that continues through all the pages in site) and calling that page in each and every page, I made that page, but I dont know how to call that page in all my pages, Could anybody help me? Thanks for your help. |
|
|
|
Sep 10 2004, 05:46 PM
Post
#2
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 7 Joined: 10-September 04 Member No.: 452 |
Yes, in order to make your website look uniform you could use the same coding, but what I would do is use a css script with a set defined styles for your text, tables, and background. By using a css script, you will save yourself the trouble of having to edit very long html files. This will help you change the look of your page instantly by only editing one file and make the website as a whole look more professional. That is what I would do.
|
|
|
|
Sep 12 2004, 07:46 AM
Post
#3
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 6 Joined: 12-September 04 From: Denver, CO, USA Member No.: 502 |
There is no way (that I know) to 'call' a template page from another HTML page. In order to do this, you have to use PHP or similar server-side processing. But here's what I would suggest:
Create your 'template' file in such a way that all the content which changes from page to page is localized in a few areas. Indicate the location of the content with HTML comments. Save this file on your hard drive as 'template.html'. It might look something like this (a snippet from one of my own templates): CODE <td class="main"> <!-- CONTENT GOES HERE --> </td> All the primary content for the page will always go in that one table cell. When I want to create a new page, I bring up template.html and replace the comment with my content, then save the new file under a different name (preserving the original template file). The upside is that once your template is created, you can concentrate on creating content and not have to worry about page layout anymore. The downside is that all your HTML code still resides in each and every page; if you want to make a global change to your layout, you have to edit every single page. Like I said above, you really need PHP to get the effect you're seeking. If your host supports PHP (like Astahost), this is simple. In this example, I'm assuming that all your HTML above and below the content never changes.
Hope that helps, SinisterMinisterX |
|
|
|
Sep 13 2004, 10:30 PM
Post
#4
|
|
|
Newbie [ Level 2 ] Group: [HOSTED] Posts: 12 Joined: 13-September 04 From: San Julián, Ovalle, Chile Member No.: 551 |
Like SinisterMinister X said, the only way to obtain what you want is using php or other server languaje. Continuing with his second suggestion: In the header we normally need that at least the page title change, so you need to include a variable wich defines it, something like this:
File: header.php CODE <?php if !isset ($page_title){ // If is $page_title is not set, then a default title is assigned $page_tile="Default Title";} ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title> <?php echo $page_title; ?> </title> </head> The value of $page_title can be defined in the template, like this: File: template.php CODE <?php $page_title="Put your title here"; // Don't forget to edit when adding a new page include "header.php"; ?> <body> HERE GOES YOUR BODY </body> <?php include "footer.php"; ?> As an alternative, you can define the $page_title value in the link to your page and even you can use only your template.php (in your server) to display all the pages of your site. To do this you need especify a new variable for the file name of the body, like $body. Assuming that you put all your bodies in a folder named bodies/, the link in your menu should be something like this: http://yourdomain.com/template.php?page_title=Your Title&body=bodies/anyname.txt The template must be something like this: File: template.php CODE <?php include "header.php"; include $body; // the <body></body> tags in this case must be in anyname.txt include "footer.php"; ?> Aditional tip:
|
|
|
|
| stillkill |
Sep 16 2004, 04:36 PM
Post
#5
|
|
Guests |
QUOTE(suicide @ Sep 10 2004, 03:16 PM) Hello All, I am very new to this site, and even to web development. I was given a task to make a site using html(and anything I am intrested in). This site would have a common template along all the pages in it. Now what I want is, Is there any way to define a template using HTML. If yes how? If no, what is the other easiest option for it. I dont like to code the sanme stuff in all the pages. Is there any way of data reusability. I thought of some other way, like making a page with the template(that continues through all the pages in site) and calling that page in each and every page, I made that page, but I dont know how to call that page in all my pages, Could anybody help me? Thanks for your help. the basic code for html is.... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> </body> </html> |
|
|
|
Sep 17 2004, 02:54 AM
Post
#6
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 2 Joined: 17-September 04 Member No.: 644 |
i would put another way to do it. but i cant think of anymore. you can find some stuff at http://www.flamingtext.com
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 2nd December 2008 - 04:00 PM |