Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Idea to help all those who store templated pieces in DBs

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
WO-Jacob
Smarty n00b


Joined: 16 Jan 2006
Posts: 3
Location: Lansing, MI

PostPosted: Mon Jan 16, 2006 9:48 am    Post subject: Idea to help all those who store templated pieces in DBs Reply with quote

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! Very Happy
_________________
Jacob - WebOnce Technologies
http://www.webonce.com/
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Mon Jan 16, 2006 2:26 pm    Post subject: Reply with quote

http://smarty.php.net/manual/en/templates.from.elsewhere.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website
WO-Jacob
Smarty n00b


Joined: 16 Jan 2006
Posts: 3
Location: Lansing, MI

PostPosted: Mon Jan 16, 2006 3:25 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
WO-Jacob
Smarty n00b


Joined: 16 Jan 2006
Posts: 3
Location: Lansing, MI

PostPosted: Mon Jan 16, 2006 5:43 pm    Post subject: Reply with quote

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. Smile
_________________
Jacob - WebOnce Technologies
http://www.webonce.com/
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP