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

Database driven templates, with a slight twist

 
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 -> Smarty 3
View previous topic :: View next topic  
Author Message
glennj
Smarty n00b


Joined: 09 Sep 2010
Posts: 3

PostPosted: Thu Sep 09, 2010 10:52 am    Post subject: Database driven templates, with a slight twist Reply with quote

I've extented the Smarty 3 class and implemented a database driven version of the system which works fine and was nice and easy to achieve.

However, using this method the system will check the database for a timestamp on every request. I would like to avoid this Smile

The system I am developing has an administration system where the templates are edited, so therefore the system knows when a template is updated and shouldn't really need to check on each page load.

What I would like to be able to do is recompile the Smarty template when a user saves a new version and avoid the timestamp check on each request. Does anyone have any suggestions on how to achieve this?

Thanks
Back to top
View user's profile Send private message
glennj
Smarty n00b


Joined: 09 Sep 2010
Posts: 3

PostPosted: Thu Sep 09, 2010 12:46 pm    Post subject: Reply with quote

I've worked out a solution I think.

When updating a template in my database (via the admin system) I'll call the following to force the refresh.

$smarty->utility->clearCompiledTemplate();


And then in the function that gets the timestamp from the DB, I'll ignore the database and simply return the same static number each time, forcing the system to never update or make a DB call.
Back to top
View user's profile Send private message
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 -> Smarty 3 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