|
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 |
Nick W Smarty Rookie
Joined: 23 May 2003 Posts: 22
|
Posted: Mon Sep 08, 2003 7:25 am Post subject: Caching Just One Part of a Page |
|
|
I'm sure I read this is possible but can't find the right bit in the manual:
I have pages with multiple cache_id's set at 24hrs but need to include a footer that should cache for 6mts.
Could someone point me in the right direction please?
Many thanks...
Nick |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Mon Sep 08, 2003 7:51 am Post subject: |
|
|
you can use an {insert}-function that modifies $smarty->cache_lifetime, fetches the footer and restores the original $smarty->cache_lifetime.
if it is really only the footer and will always only be the footer: a simpler approach but less flexible and IMHO not that nice would be in php (where you call display()):
$smarty->display($content, $cache_id, ...);
$smarty->cache_lifetime = 360;
$smarty->display('footer.tpl', $cache_id, ...);
HTH
messju |
|
Back to top |
|
Nick W Smarty Rookie
Joined: 23 May 2003 Posts: 22
|
Posted: Mon Sep 08, 2003 8:30 am Post subject: |
|
|
Thanks very much, my apologies for being a pain buy might i get you to give an example?
The idea is to have the insert be a randomly generated link but that it should be cached for six months whilst the rest of the template is cached for 24hrs...
Weird I know, but it does make sense in my app. honest!
Nick |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Mon Sep 08, 2003 8:51 am Post subject: |
|
|
help? examples? on monday?
... just kidding.
a very simple solution (this came to my mind after my first response);
in your php-file, where you call display of the 24hrs-cached page do this (untested):
$smarty->cache_lifetime = 24*3600*6*30; /* about 6 months */
$smarty->assign('banner', $smarty->fetch('banner.tpl'));
$smarty->cache_lifetime = 24*3600; /* 24hrs */
$smarty->display('index.tpl');
and in you index.tpl you can put your banner-code somewhere simply with {$banner}. |
|
Back to top |
|
Nick W Smarty Rookie
Joined: 23 May 2003 Posts: 22
|
Posted: Mon Sep 08, 2003 8:56 am Post subject: |
|
|
Very neat. A far simpler solution, a bit beyond me on a monday aswell heh!
Thanks very much, will give it a go..
Nick |
|
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
|