Page 1 of 1

I need help on making a template system

Posted: Sun May 23, 2004 6:53 pm
by Xephon
I need some help finding a tutorial or such to help me make a basic one.

im looking for some full ones, hopefully basic ones though, since I'm somewhat new. The simpler the better, I just wanna learn the basics then try my hand at it.

thx in advance

I figured out that a lot of ppl dont like template systems. They say it is not really good to have to learn a whole new language.

but then i see a lot of ppl who like them too.

I think i still wanna try it, but I still cannot find a good tutorial for a basic template system. I have searched the web and many forums, and no tutorials seem to be worth reading (to me, since they are not what I want - they either try and work around using template engines, or try and use existing template engines). I want to find a way to make my own system, but maybe veer away from having to write my own language.

I dont know if that is possible though

Posted: Sun May 23, 2004 10:05 pm
by d3ad1ysp0rk
engine = word that actually means set of functions that do the stuff to display your template
no need to learn a new language, you only need php. unless by new language, you meant php.. heh

basic one:
url example: site.com/index.php?id=news

index.php:

Code: Select all

<?php
if(empty($_GET['id'])){ $id = "home"; }
else { $id = $_GET['id']; }
include("header.txt");
include($id . "txt");
include("footer.txt");
?>
header.txt:

Code: Select all

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;my site!&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="linktostyle.css" /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="header"&gt;&lt;img src="banner.jpg"&gt;&lt;/div&gt;
&lt;div id="menu"&gt;&lt;a href="index.php"&gt;Home&lt;/a&gt; - &lt;a href="index.php?id=news"&gt;News&lt;/a&gt; - &lt;a href="index.php?id=contact"&gt;Contact&lt;/a&gt;&lt;/div&gt;
&lt;div id="content"&gt;
footer.txt:

Code: Select all

&lt;div id="footer"&gt;Copyright badkdni 2004-2006. Hosted by fnfg&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
home.txt:

Code: Select all

Welcome to my site! blah blah blah!&lt;br /&gt;&lt;br /&gt;
I have lots of pages on my site and a pretty new templating system! yay!
news.txt:

Code: Select all

4/2/04: updated stuff! &lt;br /&gt;
5/6/04: morrrrre stuffff&lt;br /&gt;
5/7/04: yup.&lt;br /&gt;
contact.txt:

Code: Select all

email: fuhgvf@hufdgbjf.com
aim: blargity!
msn: word@yo.homie_O_o
Yup. Pretty basic..

Posted: Mon May 24, 2004 4:17 pm
by Xephon
koo thx for the help :)

Posted: Mon May 24, 2004 4:34 pm
by jason