Re: Please help on caching

From: Date: Mon, 31 Dec 2001 23:45:02 +0000
Subject: Re: Please help on caching
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2459@lists.php.net to get a copy of this message
Yeah, it can't work like that, though. The login form and login status feedback is on every single page. I'd have to completely redesign my template structure in a much more confusing manner (include statements within the templates themselves, thus requiring a rewrite of all my PHP pages). If everything in 'main.tpl' is cached, it will result in login results being cached as well, which is one of the main problems, and the main reason I don't want to cache main.tpl in the first place, JUST the subtemplates. It looks like Andrei's method may help, but I have to try it out, first :) Thanks! Brian ------------------------------------ "How should I know if it works? That's what beta testers are for. I only coded it." - Linus Torvalds ----- Original Message ----- From: "Werner Schweizer" <W.Schweizer@SwissOnline.ch> To: smarty@lists.ispi.net Date: 12/31/01 6:11:43 AM > >With my solution you don't need to fetch a subtemplate. >It will be included by main.tpl. > >For your login-problem: >1. Don't cache the login form >2. Or add your section id to the cache id > > ... > $template = "depending_on_REQUEST_URI"; > if($template == "login.tpl") > { > $smarty->caching = false; > $cache_id = $template . $REQUEST_URI . $section_id; > }else > $smarty->caching = true; > $cache_id = $template . $REQUEST_URI; > } > if(!$smarty->is_cached("main.tpl", $cache_id)) > { > ... > Database access > ... > $smarty->assign("your_template_specific_variables", ...); > ... > } > $smarty->display("main.tpl", $cache_id); > >As I don't know your application, I don't know if this could be a solution >for you. >But you can probably take it as a hint. > >Werner Schweizer > >> -----Ursprüngliche Nachricht----- >> Von: Brian E. Lozier [mailto:brian@massassi.net] >> Gesendet: Sonntag, 30. Dezember 2001 22:20 >> An: smarty@lists.ispi.net >> Betreff: [smarty] Re:AW: Re: Please help on caching >> >> >> The problem with your example is that it doesn't use ->fetch() to >> get the second template. Does it still >> parse any {$var} tags inside it? Regardless, it still won't work >> for my application since it's always going >> to be caching 'main.tpl' which can't work - because if the first >> person to hit it is logged in, everyone >> after will see the 'logged in as: [nick name]' message. And if >> the first person isn't logged in, everyone >> will see the login form, regardless of whether they're logged in. >> >> Brian >> ------------------------------------ >> "How should I know if it works? That's what beta testers are for. >> I only coded it." - Linus Torvalds >> >> ----- Original Message ----- >> From: "Werner Schweizer" <W.Schweizer@SwissOnline.ch> >> To: smarty@lists.ispi.net >> Date: 12/30/01 3:24:45 AM >> >> > >> >As you certainly noticed, my previous example had errors. >> > >> >Here the correct version: >> > >> >in xx.php >> >--------- >> > >> >$template = "whatever.tpl"; // .tpl name depending >> of xx.php or >> >$REQUEST_URI >> >$smarty->assign("template",$template); >> >$smarty->assign("contents",$contents); // $contents filled by xx.php >> > >> >$smarty->display('main.tpl', $template . $REQUEST_URI); >> > >> >main.tpl >> >-------- >> > >> ><html> >> ><body> >> > {if !empty($template)} >> > {include file=$template} >> > {else} >> > <h1>Error: No template specified</h1> >> > {/if} >> ></body> >> ></html> >> > >> >This way the caching should work and has an unique id. >> >Maybe you don't nead both, $template and $REQUEST_URI >> >as cache id if your $template is a unique result of $REQUEST_URI. >> > >> >Werner Schweizer >> > >> > >> > >> >--- >> >You are currently subscribed to smarty as: brian@massassi.net >> >To unsubscribe send a blank email to $subst('Email.Unsub') >> >Visit Smarty's homepage at >> >http://www.phpinsider.com/php/code/Smarty/ >> >> >> --- >> You are currently subscribed to smarty as: W.Schweizer@SwissOnline.ch >> To unsubscribe send a blank email to $subst('Email.Unsub') >> Visit Smarty's homepage at >> http://www.phpinsider.com/php/code/Smarty/ >> > > > >--- >You are currently subscribed to smarty as: brian@massassi.net >To unsubscribe send a blank email to $subst('Email.Unsub') >Visit Smarty's homepage at >http://www.phpinsider.com/php/code/Smarty/

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