|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
WO-Jacob Smarty n00b
Joined: 16 Jan 2006 Posts: 3 Location: Lansing, MI
|
Posted: Mon Jan 16, 2006 9:48 am Post subject: Idea to help all those who store templated pieces in DBs |
|
|
Hey guys, I don't know if anyone else will think this is a good idea, but it would sure help me out a bunch.
I would do this myself, but I can't make much of smarty's innards, and can't seem to tell where this would best go...
Anyway, without further ado...
What I would like to see, are versions of ->fetch() and ->display() that work from content strings, and not from template files.
Basically, what I do a lot, is store the template in the database (be it emails, or now small page fragments), and I would really love to have a 'less overhead' way of getting those templates processed than having to create junk temporary template files.
Anyone know of a way to do this currently or think this is a decent idea? It would help me out a TON! _________________ Jacob - WebOnce Technologies
http://www.webonce.com/ |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
|
Back to top |
|
WO-Jacob Smarty n00b
Joined: 16 Jan 2006 Posts: 3 Location: Lansing, MI
|
Posted: Mon Jan 16, 2006 3:25 pm Post subject: |
|
|
messju wrote: | http://smarty.php.net/manual/en/templates.from.elsewhere.php |
Oh wow, that's awesome. I don't know how I missed that. _________________ Jacob - WebOnce Technologies
http://www.webonce.com/ |
|
Back to top |
|
WO-Jacob Smarty n00b
Joined: 16 Jan 2006 Posts: 3 Location: Lansing, MI
|
Posted: Mon Jan 16, 2006 5:43 pm Post subject: |
|
|
WO-Jacob wrote: | messju wrote: | http://smarty.php.net/manual/en/templates.from.elsewhere.php |
Oh wow, that's awesome. I don't know how I missed that. |
Code: |
function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
{
// do database call here to populate $tpl_timestamp.
$sql = new SQL;
$sql->query("select tpl_timestamp
from my_table
where tpl_name='$tpl_name'");
if ($sql->num_rows) {
$tpl_timestamp = $sql->record['tpl_timestamp'];
return true;
} else {
return false;
}
}
|
You may want to mention somewhere in here... that it expects the 'timestamp' to be un unixtime. I spent a little fun while trying to figure out why my templates were not updating. _________________ Jacob - WebOnce Technologies
http://www.webonce.com/ |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|