| Mark Watkins 2005-02-25, 4:02 pm |
| Hi there..
I'm trying to find a very simple way to eval a block of code that I retrieve
alongside with the templates from a database. I need to call this code before
displaying the template, and would rather do it during processing than having
to explicitly know it's going to be used, before the initial
$smarty->display("db:layout");
Being lazy, I don't want to have to do anything in my templates other than
what I usually do: {include file="db:whatever"} I just want smarty to
callback to one of my functions with at least the template_name, before it
does it's stuff.
Caching interferes with me trying to (mis)use the normal template fetch
related callbacks, timestamp & security callbacks kind of worked, but
sometimes get called twice.
Currently, I am preloading the bits of code I need run into derived classes
beforehand, and calling {$preloaded.modulename->execute()} inside my
templates, which runs my code, which can indirectly call smarty to display
it's own templates in the middle of the one it's displaying.
I could probably use autoloading to make these classes appear magically, but
I've already pinched that to generate a neat little generic class for
accessing database tables, and don't wanna have to use prefixes.
Any Ideas?
/Mark
|