mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-15 21:45:21 +02:00
- bugfix in nested {foreach} saved item attributes got overwritten https://github.com/smarty-php/smarty/issues/33
This commit is contained in:
@@ -208,7 +208,8 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase
|
||||
}
|
||||
}
|
||||
}
|
||||
$output .= "\$foreachItemSav = \$_smarty_tpl->tpl_vars[$item];\n";
|
||||
$itemName = trim($item,"'\"");
|
||||
$output .= "\$foreach_{$itemName}_Sav = \$_smarty_tpl->tpl_vars[$item];\n";
|
||||
$output .= "?>";
|
||||
|
||||
return $output;
|
||||
@@ -239,8 +240,9 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
|
||||
|
||||
list($openTag, $nocache, $item, $key, $foo) = $this->closeTag($compiler, array('foreach'));
|
||||
$this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $item, $key, false));
|
||||
$itemName = trim($item,"'\"");
|
||||
$output = "<?php\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$item] = \$foreachItemSav;\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$item] = \$foreach_{$itemName}_Sav;\n";
|
||||
$output .= "}\n";
|
||||
$output .= "if (!\$_smarty_tpl->tpl_vars[$item]->_loop) {\n?>";
|
||||
return $output;
|
||||
@@ -274,9 +276,10 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
|
||||
}
|
||||
|
||||
list($openTag, $compiler->nocache, $item, $key, $restore) = $this->closeTag($compiler, array('foreach', 'foreachelse'));
|
||||
$itemName = trim($item,"'\"");
|
||||
$output = "<?php\n";
|
||||
if ($restore) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$item] = \$foreachItemSav;\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$item] = \$foreach_{$itemName}_Sav;\n";
|
||||
}
|
||||
$output .= "}\n?>";
|
||||
|
||||
|
Reference in New Issue
Block a user