Re: [SMARTY] Newbie question... last modified timestamp
| From: | Andrei Zmievski | Date: | Tue, 16 Apr 2002 13:12:12 +0000 |
| Subject: | Re: [SMARTY] Newbie question... last modified timestamp | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-3767@lists.php.net to get a copy of this message | ||
On Mon, 15 Apr 2002, Mieu d'Iscalio Sedai wrote:
> Sorry for the long winded explanation, but... what I really want to know is
> if there's a Smarty function that can get this timestamp for me. But if not,
> could anyone suggest to me a good way of retrieving the "last modified"
> timestamp with php code?
There is no such function, but it would be pretty simple to write one.
<?php
function smarty_compiler_last_modified($arg, &$smarty)
{
$args = $smarty->_parse_attrs($arg);
$lastmod = filemtime($smarty->template_dir . '/' . $smarty->_current_file);
if (empty($args['format']))
$format = '"%c %Z"';
else
$format = $args['format'];
return "echo strftime($format, $lastmod);";
}
?>
Just put it in a file called compiler.last_modified.php in your plugins
directory.
-Andrei
"Tomorrow the sun will rise. And who knows what the tide will bring?"
- Tom Hanks, in "Cast Away"