Re: [SMARTY] {nocache}
| From: | Darryl Bleau | Date: | Thu, 06 Feb 2003 18:44:01 +0000 |
| Subject: | Re: [SMARTY] {nocache} | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7563@lists.php.net to get a copy of this message | ||
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:-- Darryl Bleau, B.Sc CS, A+ Creative Director Submersion Corporation Submersion.com 1-780-608-1616So 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