Page 1 of 1

Smarty

Posted: Tue Nov 06, 2007 11:56 pm
by Mr Tech
Do you guys recommend the Smarty template engine? I'm having a play.

I also have a questions... To output a table, you need to use this code:

Code: Select all

$smarty->display("template.php");
Is there anyway to make it run something like this:

Code: Select all

$template = $smarty->display("template.php");
I need it like the above so that I can replace items within the template etc after it's been compiled..

For example, I need to include the template which is a full HTML file (it has the <html>, <head> and <body> tags) and I need to replace everything between the two <head> and </head> tags... I don't seem to be able to do that when it prints it directly on the page.

E.g:

Code: Select all

preg_match( "/\<head\>(.*?)\<\/head\>/is", $template, $head);
$template = str_replace($head[1], "<head>\n<style>".$style_sheet_code."</style>\n</head>", $template);
Any ideas or is it not possible?