|
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 |
eelco Smarty n00b
Joined: 19 Aug 2015 Posts: 3
|
Posted: Wed Sep 23, 2015 4:35 pm Post subject: Variables not recognized in cache |
|
|
I am further implementing the cache functions of Smarty, and now the variables are not recognized in cache.
When my page is generated the first time, so not using cache, the page is displayed correctly. When I refresh, the cache is being used, and the variables are not recognized any more. I get the following error:
Code: | Notice: Undefined index: Products in /home/lib/smarty/smarty-3.1.27/sysplugins/smarty_cacheresource_keyvaluestore.php(104) : eval()'d code on line 90 |
My code (in short):
Code: |
if(!$smarty->isCached('category.html', 'key'))
{
/**
* Load data
*/
$x = array();
/**
* Save variable
*/
$smarty->Assign('Products', $x);
}
/**
* Display page
*/
$smarty->Display('category.html', 'key');
|
EDIT: I now found I have a {nocache}-part in the template where I call the $Products variable. I believe this produces the error. Is there a way around this? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed Sep 23, 2015 4:53 pm Post subject: |
|
|
Sounds like your variable somehow left 'nocache'd. Can't tell without seeing exact template code.
Also, make sure you are not misspelling method names.
P.S.
And that caching is actually enabled, and not overridden. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Sep 24, 2015 7:13 pm Post subject: |
|
|
Variables used in {nocache} sections must be always assigned, not only when the cache is invalid. Thats the purpose of a nocache section that variables are dynamic and not cached...... |
|
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
|