Caching of Variables Set Within a User-Defined Tag
Posted: Fri Apr 14, 2006 6:07 pm
I'm trying to set a variable within a user-defined tag so that a later {if} can toggle content. I've tried using a technique previously posted in the forum; however, the value of the variable gets cached the first time the page is loaded and doesn't get updated unless the page is edited or the cache is cleared. (This is in 0.12.1.)
Here's a simple example using the time to the second as a value to illustrate the issue.
A tag called {get_date}:
A page that loads it:
The page results showing the time not being updated come out something like this:
All insight appreciated!
FYI, the actual code I'm trying to debug looks like this:
Here's a simple example using the time to the second as a value to illustrate the issue.
A tag called {get_date}:
Code: Select all
//$smarty->caching=false;
$d = date("H:i:s");
echo "Inside get_date ($d) <br />";
$smarty->assign($params['var'], $d);
Code: Select all
Value before call:({$ret_val})<br />
{get_date var='ret_val'}
Value after call:({$ret_val})<br />
I tried toggling $smarty->caching, but the results are unpredictable. On some machines I get the desired behavior, on others I see {nocache} output in the page, and on others the tag gets called twice.Value before call:()
Inside get_date (10:54:10)
Value after call:(10:53:50)
All insight appreciated!
FYI, the actual code I'm trying to debug looks like this:
Code: Select all
$userid = get_userid(false);
$smarty->caching=false;
$smarty->assign($params['var'],(check_permission($userid, $params['name']) ? 1:0));