I need help on making a template system

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Xephon
Forum Newbie
Posts: 20
Joined: Sat May 15, 2004 10:58 pm

I need help on making a template system

Post 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
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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..
Xephon
Forum Newbie
Posts: 20
Joined: Sat May 15, 2004 10:58 pm

Post by Xephon »

koo thx for the help :)
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Post Reply