diff --git a/include/template.php b/include/template.php index b262bf46c..f58b7a0e3 100644 --- a/include/template.php +++ b/include/template.php @@ -243,6 +243,30 @@ class Template { return true; } + /** + * Block-level variable merge. Merge given variables to the last block + * iteration. This can be called several times per block iteration. + */ + function merge_block_vars($blockname, $vararray) + { + $blocks = explode('.', $blockname); + $blockcount = count($blocks); + $str = '$this->_tpldata'; + for ($i = 0; $i < $blockcount; $i++) + { + $str .= '[\'' . $blocks[$i] . '.\']'; + eval('$lastiteration = isset('.$str.') ? sizeof('.$str.')-1:-1;'); + if ($lastiteration==-1) + { + return false; + } + $str .= '[' . $lastiteration . ']'; + } + $str = $str.'=array_merge('.$str.', $vararray);'; + eval($str); + return true; + } + /** * Root-level variable assignment. Adds to current assignments, overriding * any existing variable assignment with the same name.