Re: [SMARTY] Retrieve timestamp for template - how?
| From: | messju mohr | Date: | Tue, 10 Feb 2004 12:39:57 +0000 |
| Subject: | Re: [SMARTY] Retrieve timestamp for template - how? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10942@lists.php.net to get a copy of this message | ||
On Tue, Feb 10, 2004 at 01:16:54PM +0100, Tommy Ipsen wrote:
> Hi group
>
> I've modified smarty to fetch templates from a database using PEAR::DB by
> registering 'db' as a ressource using:
>
> $smarty->register_resource('db', array($smarty, 'db_get_template',
> 'db_get_timestamp', 'db_get_secure', 'db_get_trusted'));
>
> I'm interested in getting the timestamp for the current template to output:
>
> "Page last modified the ...."
>
> What would be the proper/correct way to fetch this timestamp - Is it even
> necessary to call a function or is the information allready somewhere in
> some variable within the smarty class?
>
> I was thinking of registering a function like this:
>
> $smarty->register_function('date_modified', array($smarty,
> 'print_modified_date'));
>
> - I have the method 'print_modified_date' in my extended smarty class and
> it looks like this:
>
> function print_modified_date($params) {
> // WHAT TO DO HERE!?
> $this->db_get_timestamp(); //... ?
> if(empty($params['lang']))
> $lang = 'da_DK';
> else
> $lang = $params['lang'];
>
> $dateTime = new I18N_DateTime($lang);
>
> if(empty($params['format']))
> $format = I18N_DATETIME_FULL;
> else
> $format = $params['format'];
>
> // get the last modified time of the current template in the
> supplied format
> return $dateTime->format("timestamp from template...", $format);
> }
>
> I'm sure there is an easy way of doing this... but how :-)
The only way I know to retrieve this is Smarty::_fetch_resource_info()
But this function is an internal one, It's api may change in future
version of Smarty.
> Thanks in advance for helping out!
>
> Regards, Tommy Ipsen
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php