RE: [SMARTY] {nocache}
| From: | Andrew S. Nagy | Date: | Thu, 06 Feb 2003 19:20:17 +0000 |
| Subject: | RE: [SMARTY] {nocache} | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7564@lists.php.net to get a copy of this message | ||
Darryl, Im not sure about the nocache ideas. One way i accomplished this is
by setting a cache group for each session. If you app is managed by
sessions, each session can have their own caches. So a user can log in and
see the welcome page and have that cached with their own name in it.
Hope this idea helps, check out the smary documentation on cache grouping
Andrew Nagy
> -----Original Message-----
> From: Darryl Bleau [mailto:darrylbleau@submersion.com]
> Sent: Thursday, February 06, 2003 1:44 PM
> To: Smarty (E-mail)
> Subject: Re: [SMARTY] {nocache}
>
>
> Sorry I should have been more specific.
>
> What I mean is, when you have $smarty->caching on, if you have something
> like: (very simplified)
>
> index.php
> $arow = $mydb->query("select name from users where
> id=$_REQUEST['userid']");
> $smarty->assign("username",$arow['name']);
>
> then
>
> index.tpl
> Hi there {$username}!
>
> It won't matter what the userid request is changed to, it's always going
> to display the user name of the first user who accessed the page
> (because it's cached). You can do this:
>
> index.php
> function insert_getUsername()
> {
> ... (get the user name)
> return $username;
> }
>
> then
>
> index.tpl
> Hi there {insert name="getUsername"}!
>
> Then that will always give you back the right username, but the rest of
> the page will be cached (am I correct on this? I think I am).
>
> What I was thinking was this:
>
> index.php
> $arow = $mydb->query("select blah blah blah");
> $smarty->assign("username",$arow['name']);
>
> then
>
> index.tpl
> Hi there {nocache}{$username}{/nocache}!
>
> Then Smarty would know that because $username was in nocache tags that
> it should dynamically generate that data each time... though I suppose
> this would also involve setting sections in the PHP code so that Smarty
> would know what to run to generate the result..
>
> Ok hmm... maybe this isn't so easy to implement. But my primary question
> was whether or not I had actually seen this mentioned before.. maybe
> someone else has a better idea on how to make it work :)
>
>
>
> John Wards wrote:
>
> >On Thursday 06 Feb 2003 6:28 pm, Darryl Bleau wrote:
> >
> >
> >>So is this a planned feature, and if not, is it at all possible? Seems
> >>like it would make coding templates which are mostly cached but have
> >>some data that you always want dynamic much easier.
> >>
> >>
> >
> >I am confuzed at what you mean by dynamic in templates.
> >
> >If you have a look at my site www.sportnetwork.net/main/s14 for
> example that
> >is complealy dynamic and generated from the database.
> >
> >John
> >
> >
> >
>
> --
> Darryl Bleau, B.Sc CS, A+
> Creative Director
> Submersion Corporation
> Submersion.com
> 1-780-608-1616
>
>