Pompiuses
11-08-2003, 02:42 PM
I'm about start developing a new site using templates. I have no experience using templates so after searching the forum and reading about it I think i got the general idea. I made this simple example to illustrate how I think using templates might look like:
index.php
<?php
class Collect_Data
{
var $title;
var $content;
function Collect_Data()
{
$this->title = 'Template Test';
$this->content = 'Here is content';
$this->Print_Template();
}
function Print_Template()
{include('index.tpl');}
function Print_Title()
{echo $this->title;}
function Print_Content()
{echo $this->content;}
}
new Collect_Data();
?>
index.tpl
<html>
<head>
<title><?php $this->Print_Title(); ?></title>
</head>
<body>
<h1><?php $this->Print_Content(); ?></h1>
</body>
</html>
This would allow me to change the appearance of the site without changing my php code. Now I wonder if I've gotten this right!? Is this how templates should be used?
Any thoughts are appreciated :)
index.php
<?php
class Collect_Data
{
var $title;
var $content;
function Collect_Data()
{
$this->title = 'Template Test';
$this->content = 'Here is content';
$this->Print_Template();
}
function Print_Template()
{include('index.tpl');}
function Print_Title()
{echo $this->title;}
function Print_Content()
{echo $this->content;}
}
new Collect_Data();
?>
index.tpl
<html>
<head>
<title><?php $this->Print_Title(); ?></title>
</head>
<body>
<h1><?php $this->Print_Content(); ?></h1>
</body>
</html>
This would allow me to change the appearance of the site without changing my php code. Now I wonder if I've gotten this right!? Is this how templates should be used?
Any thoughts are appreciated :)