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

Replace bits of code in template for cache....

 
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 Development
View previous topic :: View next topic  
Author Message
Jeremy-
Smarty Rookie


Joined: 11 Feb 2005
Posts: 16

PostPosted: Thu May 19, 2005 7:53 am    Post subject: Replace bits of code in template for cache.... Reply with quote

Is it possible to replace content on the fly within the Smarty .tpl file, and then have the result cached?

For example, let's say I have my own mini-template engine within the framework I am using Smarty for... I have an easy method set up for users to create input fields that allow dynamic class change if for some reason the posted content is invalid.

The input is defined in the .tpl file as such:

<!--input:password:: accesskey:p, label:lang->password, name:password, id:password-->

That gets parsed through a function and is returned as a new variable. So, is there a way to take all the <!--input... within the template and replace it with the actual returned variable for the cache file? I know I could solve a lot of headache by making the input itself a variable and configuring it's attributes in framework source, but that defeats the point of what abilities I'd like to give to the end user administrator.

--------

If what I posted sounds too complicated, I'll say it like this. Is there a way I could replace the text "<!--hey--> in the .tpl file with the actual text "hey this is some text" in the cache file. I hope that makes sense...

Any advice what-so-ever is greatly appreciated.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu May 19, 2005 11:10 pm    Post subject: Reply with quote

I'm not sure I follow entirely but it seems like you should either consider using a plugin function that you register as non-caching or otherwise either a compiler-plugin or a prefilter.

Check them out and then ask if you have specific questions.
Back to top
View user's profile Send private message
Jeremy-
Smarty Rookie


Joined: 11 Feb 2005
Posts: 16

PostPosted: Sun May 22, 2005 8:13 pm    Post subject: Reply with quote

Thanks, I have it working now using a custom function. Once it's more developed, I'll look into making it available to anyone else that needs it.
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 Development 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