Re: [SMARTY-DEV] patch for run function
| From: | Jason Sweat | Date: | Sun, 02 Mar 2003 02:42:12 +0000 |
| Subject: | Re: [SMARTY-DEV] patch for run function | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-882@lists.php.net to get a copy of this message | ||
Hi Tom,
I have not taken the time to completly review your patch, but I think if I
wanted to implement this kind of functionality, I would probably just extend
my custom smarty class to override the display function.
i.e.
class my_smarty extends smarty {
function display($tpl)
{
$this->assign('myvar', 'myval');
parent::display($tpl);
}
}
Jason
----- Original Message -----
From: "Tom Sommer" <webmaster@tsn.dk>
To: <smarty-dev@lists.php.net>
Sent: Saturday, March 01, 2003 7:55 PM
Subject: [SMARTY-DEV] patch for run function
> Only one thing is lacking in smarty (IMO), the ability to assign variables
> just before displaying a page, this patch is a starter for such a function
>
> What this is used for is to display things such as execution time etc.
>
> Here is an example of what a function could do
>
> function smarty_runfunction_setexecutiontime (&$smarty)
> {
> global $time_start;
>
> $smarty->assign('PARSETIME', round(getmicrotime() - $time_start,5));
>
> }
>
> Each time a template is _displayed_ ( $smarty->display() ) these variables
> will be set.
>
> Things such as number of MySQL queries etc can also be included
>
> Anyway, consider this patch... I will be happy to have any comments
>
> The reason I made this is because I need it, and I've heard some other
> people also need it also
>
> PS. No need to say this function is NOT run when smarty is doing cached
> pages :)
>
> PATCH: http://dev.tsn.dk/smarty.patch.runfunction.txt
>
> Any comments?
> --
> Tom Sommer, denmark
> www.tsn.dk - www.dreamcoder.dk
>
> --
> Smarty Development Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>