AW: Re:AW: Re: Please help on caching
| From: | Werner Schweizer | Date: | Mon, 31 Dec 2001 14:11:43 +0000 |
| Subject: | AW: Re:AW: Re: Please help on caching | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2453@lists.php.net to get a copy of this message | ||
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/
>