Smarty

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Smarty

Post 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?
Post Reply