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

variables are not passed if within a nocache block

 
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 -> Bugs
View previous topic :: View next topic  
Author Message
edelacruz
Smarty Rookie


Joined: 10 May 2010
Posts: 25

PostPosted: Fri Jun 20, 2014 8:51 pm    Post subject: variables are not passed if within a nocache block Reply with quote

This is easiest explained by an example.

I have three templates: MainLayout.tpl, Product.tpl, MediaTile.tpl

MainLayout.tpl
HTML container that contains the html, head, title, etc. tags. It has one {block} section named "PAGE_CONTENT".

Product.tpl
Product page contents. Inherits from MainLayout.tpl

MediaTile.tpl
Image/video thumbnail. Can show several of them on one page using {include}.


Product.tpl implementation example 1
(this works as expected. MediaTile.tpl is rendered using the passed arguments PROVIDER_ICON_CLASS and MEDIA_ICON_CLASS):

Code:

{extends file="MainLayout.tpl"}
{block name="PAGE_CONTENT"}
   {include file="MediaTile.tpl" PROVIDER_ICON_CLASS="IconYouTube" MEDIA_ICON_CLASS="IconVideo"}
{/block}



Product.tpl implementation example 2
The only difference is that the content in Product.tpl is inside a nocache block.
(this DOES NOT work as expected. I get this error: "Undefined index: PROVIDER_ICON_CLASS"):

Code:

{extends file="MainLayout.tpl"}
{block name="PAGE_CONTENT"}
   {nocache}
   {include file="MediaTile.tpl" PROVIDER_ICON_CLASS="IconYouTube" MEDIA_ICON_CLASS="IconVideo"}
   {/nocache}
{/block}



Here is the smarty portion of the stack when the exception occurs (note: I have Smarty compressed into phar.):
C:\xampp\vhosts\shared\Wafl\Extensions\Smarty3\Smarty3.php: 123
Smarty_Internal_TemplateBase->fetch

phar://C:/xampp/vhosts/shared/Wafl/Extensions/Smarty3/Smarty3.1.17.phar/sysplugins/smarty_internal_templatebase.php: 254
eval

phar://C:/xampp/vhosts/shared/Wafl/Extensions/Smarty3/Smarty3.1.17.phar/sysplugins/smarty_internal_templatebase.php(254) : eval()'d code: 385
Smarty::mutingErrorHandler

phar://C:/xampp/vhosts/shared/Wafl/Extensions/Smarty3/Smarty3.1.17.phar/Smarty.class.php: 1462
call_user_func


Thanks in advance.


Last edited by edelacruz on Fri Jun 20, 2014 8:55 pm; edited 1 time in total
Back to top
View user's profile Send private message
edelacruz
Smarty Rookie


Joined: 10 May 2010
Posts: 25

PostPosted: Fri Jun 20, 2014 8:53 pm    Post subject: Reply with quote

Smarty version 3.1.17.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sat Jun 21, 2014 9:00 am    Post subject: Reply with quote

This fix is now in the SVN trunk and will later be included in 3.1.19
Back to top
View user's profile Send private message
edelacruz
Smarty Rookie


Joined: 10 May 2010
Posts: 25

PostPosted: Mon Jun 23, 2014 5:05 am    Post subject: Reply with quote

thanks.
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 -> Bugs 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