|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
voxmachina Smarty n00b
Joined: 28 Apr 2010 Posts: 2
|
Posted: Wed Apr 28, 2010 2:31 pm Post subject: Cache problem, cache->tpl_vars empty |
|
|
Hi,
i'm having a cache related problem, here's the situation:
1. I set caching on
...
$smarty->setCaching(true);
$smarty->setCacheLifetime(5);
...
$smarty->assign("somevar","somevalue");
...
display()
2. Then when trying to access tpl_vars in template i see that they are empty
...
public 'tpl_vars' =>
array
empty
...
3. but in the debug info, they are there...
...
assigned template variables:
Smarty_Variable Object (3)
->value = Array (7)
data => Array (1)
0 => Array (6)
0 => Array (15)
...
Somehow the template vars are empty at the moment of template display,
when i disable caching all goes right... |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Apr 28, 2010 3:39 pm Post subject: |
|
|
Did you try tpl_vars in the template directly? if yes how and why?
Note that tpl_vars of the template object will hold only local variables. If you use $smarty->assign() they are stored in the Smarty object.
I need more details what you did in the template for a specific answer. |
|
Back to top |
|
voxmachina Smarty n00b
Joined: 28 Apr 2010 Posts: 2
|
Posted: Wed Apr 28, 2010 4:55 pm Post subject: Test case |
|
|
Ok, i've mounted a simple test case that happens exactly the same:
1. index.php
require('../libs/Smarty.class.php');
$smarty = new Smarty;
$smarty->setCaching(true);
$smarty->assign("test","a value");
$smarty->display('index.tpl');
2. index.tpl
=> {$test} <=
3. Result on browser
=> <= (empty value) |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Apr 28, 2010 5:34 pm Post subject: |
|
|
Perhaps you have some garbage in the cache. Empty the templates_c and cache folders and try again. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|