Gerenal Ideas behind templating
Posted: Sun Mar 07, 2004 7:45 pm
As I hear more and more about it, and how it's so much better for the overall product, I've been wondering, what exactly is templating?
Obviously it's the seperation of HTML and PHP, but how exactly does it work?
Something like:
template_a.html:
then engine.php:
or am I totally off?
Please explain (with a small example if possible, or a tutorial you'd suggest). thanks
Obviously it's the seperation of HTML and PHP, but how exactly does it work?
Something like:
template_a.html:
Code: Select all
<html>
<body>
<div class="menu">{menu}</div>
<div class="body">{body}{/div>
<div class="ads">{ads}</div>
</body>
</html>Code: Select all
$page = include("templates/template_a.html");
$menu = getmenu();
$body = getbody();
$ads = getads();
$page = str_replace("{menu}",$menu,$page);
$page = str_replace("{body}",$body,$page);
$page = str_replace("{ads}",$ads,$page);
echo $page;Please explain (with a small example if possible, or a tutorial you'd suggest). thanks