Re: [SMARTY] Re: Compile time

From: Date: Fri, 21 Feb 2003 07:25:33 +0000
Subject: Re: [SMARTY] Re: Compile time
References: 1 2 3 4 5 6  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8070@lists.php.net to get a copy of this message
Hi Tom, just create a child class of Smarty (what is always a good idea): class MySmarty extends Smarty { function MySmarty() { // ... do some initialization // ... load some postfilters, prefilters, outputfilters etc. } function fetch ( ... ) { // now you can assign some vars or call some functions $this->assign('this','that'); return parent::fetch( ... ); } } I think there was a global assign in Smarty too but I cannot remember ;-) If you just want to assign vars in your function than the above way is the best I think. bye, André "Tom Sommer" <webmaster@tsn.dk> schrieb im Newsbeitrag news:9lng0s15a00n$.r8nh7z9n81i9.dlg@40tude.net... > On Thu, 20 Feb 2003 16:45:33 -0700, Darryl Bleau wrote: > > > Would it be possible at all to include a Smarty variable in a later > > release that allows you to access the compile time of the template? > > Seems like everyone wants to do this, might be nice to have a consistent > > way of doing it. Something like "{SmartyCompileTime}", which would > > return in date (so you could format it as you pleased) format the exact > > (or as close as you can get) time it took from the beginning of > > compiling the template to the end. > > I need more than compile time, since I need to display the number of mySQL > queries used to create the document, hmmm.... why can't we just have a > > function myFunction(&$smarty) > { > $smart->assign('this','that'); > // etc.. > > } > $smarty->set_compile_function('myFunction'); > > Which would define *one* function that would be run on compile time, just > before creating the final output ( $smarty->display() ) > > Although an ExecTime function would be usefull as well, returning the time > in microseconds, but you would STILL have to be able to use this variable, > so I think defining a function to be called might be the best :) > > > -- > Tom Sommer, denmark > www.tsn.dk - www.dreamcoder.dk

« previous php.smarty.general (#8070) next »