Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Time remaining for cache expiration OR cache creation time

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Stratos
Smarty n00b


Joined: 17 Sep 2003
Posts: 2

PostPosted: Wed Sep 17, 2003 9:08 pm    Post subject: Time remaining for cache expiration OR cache creation time Reply with quote

Hello,

I've combed through the manual but I cannot seem to find anywhere any option to find out when was the last time a particular template was cached, or in how much more time the template will be recreated.

In my code I use:

Code:
if (!$smarty->is_cached("results.html", $i))


As long as the page is cached, or has not expired, I delay all the DB calls and the reprocessing of the data. BUT, I'd like to output on the page something like:

Last Updated on: SomeDate/Time

or:

Next Update on: SomeDate/Time

Did I miss something, somewhere...?

Thanks
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Sep 17, 2003 9:24 pm    Post subject: Reply with quote

because the output is cached you can simply do:

$smarty->assign('now', time());
$smarty->assign('next', time()+$smarty->cache_lifetime);

and in the template:

Last Updated on: {$now|date_format}
Next Update on: {$next|date_format}

the times displayed in the template only change when the cached page expires.

[EDIT: i just remembered for the first one you can even use the special var {$smarty.now|date_format} and don't need an assign.]
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Stratos
Smarty n00b


Joined: 17 Sep 2003
Posts: 2

PostPosted: Wed Sep 17, 2003 9:27 pm    Post subject: Reply with quote

Ooops, Embarassed

The solution was easier than I thought...

I just include:

Code:
Last Updated: {$smarty.now|date_format:" %a %d-%m-%Y %H:%M"}


in my template. It will get cached and remain there until the next cache refresh, when the datetime will change again...

But, I think it will be more informative if I include the datetime of the NEXT update...


[EDITED]:

Hey, messju

We almost posted together... Thanks for your reply. I just came to the same solution
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP