Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Smarty 3.1.31 errors with section and associative arrays

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
subetha
Smarty n00b


Joined: 14 Aug 2017
Posts: 2

PostPosted: Mon Aug 14, 2017 6:17 pm    Post subject: Smarty 3.1.31 errors with section and associative arrays Reply with quote

Hello,

i have updated from Smarty 3.1.12 to 3.1.31 in order to make use of the autoloader.

I have used associative arrays so far without any issues. $data is one big array that hold all the template data. $data['categories'] is an indexed array.

But now I am seeing errors when using sections: Notice: Undefined index: __smarty_section_cat in (template_file)

Code:
{section name=cat loop=$data.categories}
  ....
{/section}


In the compiled template the faulty line reads:

Code:
$__section_men_0_total = $_smarty_tpl->tpl_vars['__smarty_section_cat']->value['loop'];


In my template i have several sections with similar data. Another one is assigned to the _same_ data and the compiled templates is:

Code:
$__section_kat_4_loop = (is_array(@$_loop=$_smarty_tpl->tpl_vars['data']->value['categories']) ? count($_loop) : max(0, (int) $_loop));


It seems that the first {section} is compiled, so that some checks are missing, but the second one is allright.

Any ideas what might be the issue?

Thanks, Christian
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Mon Nov 06, 2017 4:19 am    Post subject: Reply with quote

Hello

This was a bug when both {$smarty.section.name.loop} and{$smarty.section.name.total} had been used.

The fix is now on github in the master branch and will later be included in version 3.1.32
Back to top
View user's profile Send private message
subetha
Smarty n00b


Joined: 14 Aug 2017
Posts: 2

PostPosted: Mon Nov 06, 2017 10:31 am    Post subject: Reply with quote

Thanks!

Good to know that, looking forward to the new release.

Best, Christian
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General 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