|
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 |
elDekyfin Smarty n00b
Joined: 31 Dec 2015 Posts: 2
|
Posted: Thu Aug 25, 2016 2:56 pm Post subject: Using variable in plugins with nocache |
|
|
I display ads on various pages of my website by using a custom {ads} plugin. Although the pages are cached, I want a new ad to be loaded anytime a page is opened, even if that page is already in the cache. I use the custom plugin shown below
Code: | {ads category=$category nocache} |
This is the problem...
Anytime a page is reloaded the category parameter is empty and the plugin cannot function as intended. I would like a way to cache the "category" variable as well so it is passed to the custom plugin everytime it runs.
Thanks |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Aug 25, 2016 3:19 pm Post subject: |
|
|
You must ensure that all variables used in {nocache}{/nocache} blocks are assigned to the template before rendering.
If you have something like
Code: | if(!$smarty->isCached(cacheKey))
{
$smarty->assign(...);
} |
you should split it in two sections. Dynamic vars that are always assigned and cached vars that can be left out. |
|
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
|