Retrieve timestamp for template - how?

From: Date: Tue, 10 Feb 2004 12:16:54 +0000
Subject: Retrieve timestamp for template - how?
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10941@lists.php.net to get a copy of this message
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 :-) Thanks in advance for helping out! Regards, Tommy Ipsen

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