Jump to content

Render a string instead of template file with Smarty


Cobby

Recommended Posts

Hi,

 

I have templates stored in a database that I want to render. At the moment I just generate a temporary file and write the contents of the database query to it, the display that temporary file.

 

<?php
$result = $db->query($sql);
file_put_contents('temp.tpl', $result['content']);
$smarty->display('temp.tpl');
?>

 

But I don't like doing this as it just seems so unecessary, instead I would rather be like:

 

<?php
$result = $db->query($sql);
$smarty->render($result['content']);
?>

 

Anyway to do that?

 

Cheers,

Cobby

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.