here is the simple PHP template system i have found
The Class (template.class.php)
<?
class Template {
public $template;
function load($filepath) {
$this->template = file_get_contents($filepath);
}
function replace($var, $content) {
$this->template = str_replace("#$var#", $content, $this->template);
}
function publish() {
eval("?>".$this->template."<?");
}
}
?>
The Template File (design.html)
This file will contain the design of your web site and the blank fields that will be merged with content data.
<html>
<head>
<title>#title#</title>
</head>
<body>
<h3>Hello #name#!</h3>
<p>The time is: #datetime#</p>
<? echo "<p>Embedded PHP works too!</p>"; ?>
</body>
</html>
Usage (index.php)
Now we will create a script that load the template and use the class to merge the data.
<?
include "template.class.php";
$template = new Template;
$template->load("design.html");
$template->replace("title", "My Template Class");
$template->replace("name", "William");
$template->replace("datetime", date("m/d/y"));
$template->publish();
?>
Now for a simple wordpress post loop index.php
<?php
get_header();
if (have_posts()) :
while (have_posts()) :
the_post();
the_content();
endwhile;
endif;
?>
Question is, how to use above wordpress loop and the top PHP template system together, this is to convert an html template into a wordpress theme.