Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Cache problem, cache->tpl_vars empty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
voxmachina
Smarty n00b


Joined: 28 Apr 2010
Posts: 2

PostPosted: Wed Apr 28, 2010 2:31 pm    Post subject: Cache problem, cache->tpl_vars empty Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Apr 28, 2010 3:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
voxmachina
Smarty n00b


Joined: 28 Apr 2010
Posts: 2

PostPosted: Wed Apr 28, 2010 4:55 pm    Post subject: Test case Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Apr 28, 2010 5:34 pm    Post subject: Reply with quote

Perhaps you have some garbage in the cache. Empty the templates_c and cache folders and try again.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP