Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Templates in HTML
suicide
post Sep 10 2004, 03:16 PM
Post #1


Member [ Level 2 ]
Group Icon

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.
Go to the top of the page
 
+Quote Post
Nisshutsu
post Sep 10 2004, 05:46 PM
Post #2


Newbie [ Level 1 ]
Group Icon

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.
Go to the top of the page
 
+Quote Post
SinisterMinister...
post Sep 12 2004, 07:46 AM
Post #3


Newbie [ Level 1 ]
Group Icon

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.
  • Open your template.html file. Take all your HTML from above the content area, cut and paste it into a new file, and save the new file as 'header.php'.
  • Take all the HTML from below the content area, cut and paste into another new file, and save it as 'footer.php'.
  • Create a new file called 'template.php' which looks like this:
    CODE
    <?php include "header.php" ?>
    PAGE BODY GOES HERE
    <?php include "footer.php" ?>
  • Upload header.php and footer.php to your web space, but leave template.php on your hard drive.
  • As before, replace 'PAGE BODY GOES HERE' with your actual content, save under a new filename, and upload your new page to your web space.
This second method will allow you to make global changes to your layout easily. Any change to header.php or footer.php will instantly be included in all your content pages without changing each page manually. Just remember that every page has to be saved with a .php extension, not .html . Aside from this minor usage of PHP, you'll still be using HTML for everything else.

Hope that helps,
SinisterMinisterX
Go to the top of the page
 
+Quote Post
sanjulian
post Sep 13 2004, 10:30 PM
Post #4


Newbie [ Level 2 ]
Group Icon

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:
    Avoid using FONT and similar tags, use the css
Go to the top of the page
 
+Quote Post
stillkill
post 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>
Go to the top of the page
 
+Quote Post
neo_28052
post Sep 17 2004, 02:54 AM
Post #6


Newbie [ Level 1 ]
Group Icon

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
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Basic Tips and Tricks in HTML(15)
  2. Embedding XML into HTML(2)
  3. Converting HTML over to XHTML(13)
  4. Rapid HTML code generation using simple PHP(8)
  5. Free Gaming Clan Templates(17)
  6. Force Object To Load Last(2)
  7. Where Can I Find Good Free Website Templates(22)
  8. Creating Tooltips(7)
  9. Free Shoutbox? HTML, Flash or PHP Code(24)
  10. HTM vs HTML: Whats The Difference ?(22)
  11. Converting PSD To HTML(11)
  12. Tutorial: Dreamweaver, 3ds Max, Flash, Html, Css(8)
  13. Selling Website Templates/layouts(10)
  14. Html Basic Tutorial(9)
  15. Sitepoint's Css And Html Reference Sites(2)
  1. W3 Schools(1)
  2. Templates(4)
  3. Increase Your Knowledge Of Html Language(11)
  4. Javascript Tutorial For Beginner(0)
  5. Yaml - (x)html/css Framework(2)
  6. Style P And H? Html Tags(2)
  7. How To: Display A Members/user List.(3)
  8. Web Editor(0)
  9. Indentation In Html(4)
  10. Joomla Template Kit Extension For Nvu/composer(3)
  11. What You Need Before You Can Create A Text-based Game..(7)
  12. Basic Html Tutorial(1)
  13. Good Books For Html And Css Beginners(1)


 



- Lo-Fi Version Time is now: 2nd December 2008 - 04:00 PM