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

Caching Just One Part of a Page

 
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
Nick W
Smarty Rookie


Joined: 23 May 2003
Posts: 22

PostPosted: Mon Sep 08, 2003 7:25 am    Post subject: Caching Just One Part of a Page Reply with quote

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
View user's profile Send private message
messju
Administrator


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

PostPosted: Mon Sep 08, 2003 7:51 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Nick W
Smarty Rookie


Joined: 23 May 2003
Posts: 22

PostPosted: Mon Sep 08, 2003 8:30 am    Post subject: Reply with quote

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! Wink

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


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

PostPosted: Mon Sep 08, 2003 8:51 am    Post subject: Reply with quote

help? examples? on monday?

... Smile 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
View user's profile Send private message Send e-mail Visit poster's website
Nick W
Smarty Rookie


Joined: 23 May 2003
Posts: 22

PostPosted: Mon Sep 08, 2003 8:56 am    Post subject: Reply with quote

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
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