From 6e22abb6dde8ef2b0cf7462f17c16d983c963ac0 Mon Sep 17 00:00:00 2001 From: "uwe.tews@googlemail.com" Date: Thu, 22 Sep 2011 14:51:34 +0000 Subject: [PATCH] - bugfix {foreachelse} does fail if {section} was nested inside {foreach} --- change_log.txt | 3 +++ libs/sysplugins/smarty_internal_compile_foreach.php | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/change_log.txt b/change_log.txt index b59338c9..7999d400 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== Smarty 3.1 trunk ===== +22.09.2011 +- bugfix {foreachelse} does fail if {section} was nested inside {foreach} + 21.09.2011 - bugfix look for mixed case plugin file names as in 3.0 if not found try all lowercase - added $error_muting to suppress error messages even for badly implemented error_handlers diff --git a/libs/sysplugins/smarty_internal_compile_foreach.php b/libs/sysplugins/smarty_internal_compile_foreach.php index 5a196cb4..33bd886a 100644 --- a/libs/sysplugins/smarty_internal_compile_foreach.php +++ b/libs/sysplugins/smarty_internal_compile_foreach.php @@ -100,7 +100,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase { $usesPropTotal = $usesSmartyTotal || $usesSmartyShow || $usesPropShow || $usesPropLast || strpos($tpl->source->content, $ItemVarName . 'total') !== false; // generate output code $output = "tpl_vars[$item] = new Smarty_Variable;\n"; + $output .= " \$_smarty_tpl->tpl_vars[$item] = new Smarty_Variable; \$_smarty_tpl->tpl_vars[$item]->_loop = false;\n"; if ($key != null) { $output .= " \$_smarty_tpl->tpl_vars[$key] = new Smarty_Variable;\n"; } @@ -131,7 +131,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase { $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['show']=(\$_smarty_tpl->tpl_vars[$item]->total > 0);\n"; } } - $output .= "\$_loop = false;\nforeach (\$_from as \$_smarty_tpl->tpl_vars[$item]->key => \$_smarty_tpl->tpl_vars[$item]->value){\n\$_loop = true;\n"; + $output .= "foreach (\$_from as \$_smarty_tpl->tpl_vars[$item]->key => \$_smarty_tpl->tpl_vars[$item]->value){\n\$_smarty_tpl->tpl_vars[$item]->_loop = true;\n"; if ($key != null) { $output .= " \$_smarty_tpl->tpl_vars[$key]->value = \$_smarty_tpl->tpl_vars[$item]->key;\n"; } @@ -191,7 +191,7 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase { list($openTag, $nocache, $item, $key) = $this->closeTag($compiler, array('foreach')); $this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $item, $key)); - return ""; + return "tpl_vars[$item]->_loop) {\n?>"; } }