This is simple template function which reduces developement time..
Download
View Source (print view)
Rating : 4.7
Views : 212
//this is the function that return the template content as a string after replacing place holders[{}] to a array variable which has place holders as index.
//this fuction assumes that all template files in a folder templates and there is a varible definded $site_path to serverpath.
//$name is html file name that may be in templates folder
function do_template($name, $array="_var")
{
global $$array, $_config;
//read the template files
$content = read_file($site_path . '/templates/' . $name);
foreach ($$array as $index => $value) {
$content = str_replace("{$index}", $value, $content);
}
$content = preg_replace('#{([a-z0-9-_]*?)}#', '', $content);
return $content;
}
//to read the content of a file
function read_file($file)
{
$fp = fopen($file, 'r') or die("File Does'nt Exists");
$content = fread($fp, filesize($file));
fclose($fp);
return $content;
}
rss, fedex, xslt, i need webmail login name and password, search results, project, php script" class="neww" target="_blank" title="im neuen, unction, yahoo status check, anton sorina, guest, php snips, doc,_pdf,_rtf,_xsl__files_to_a_single_pdf_at_runtime, php script" class="neww" target="_b...', twenty_2007, paper without wood, \"php_script, yahoo_status, yahoostatus, auto loading combo box, bbcode