|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Stratos Smarty n00b
Joined: 17 Sep 2003 Posts: 2
|
Posted: Wed Sep 17, 2003 9:08 pm Post subject: Time remaining for cache expiration OR cache creation time |
|
|
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 |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Sep 17, 2003 9:24 pm Post subject: |
|
|
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 |
|
Stratos Smarty n00b
Joined: 17 Sep 2003 Posts: 2
|
Posted: Wed Sep 17, 2003 9:27 pm Post subject: |
|
|
Ooops,
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 |
|
|
|
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
|