diff options
author | rub <rub@piwigo.org> | 2007-07-09 22:13:12 +0000 |
---|---|---|
committer | rub <rub@piwigo.org> | 2007-07-09 22:13:12 +0000 |
commit | e7130ac18ca5348d06bbfb324e664f284f65f3bb (patch) | |
tree | 292e571df89b9459f66c5d0980e08109af36b712 /include/template.php | |
parent | 28a8e83485014236ad71b212d0934829d1ac91e9 (diff) |
Resolved issue 0000718: Add method "concat_var_from_handle" in template class
git-svn-id: http://piwigo.org/svn/branches/branch-1_7@2056 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/template.php')
-rw-r--r-- | include/template.php | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/include/template.php b/include/template.php index 9b4b20fa6..f4096d98a 100644 --- a/include/template.php +++ b/include/template.php @@ -214,21 +214,23 @@ class Template { */ function assign_var_from_handle($varname, $handle) { - if (!$this->loadfile($handle)) - { - die("Template->assign_var_from_handle(): Couldn't load template file for handle $handle"); - } - - trigger_action('loc_before_tpl_assign_var_from_handle', $handle, array(&$this)); - // Compile it, with the "no echo statements" option on. - $_str = ""; - $code = $this->compile($this->uncompiled_code[$handle], true, '_str'); - - // evaluate the variable assignment. - eval($code); - // assign the value of the generated variable to the given varname. - $this->assign_var($varname, $_str); + trigger_action('loc_before_tpl_assign_var_from_handle', $varname, $handle, array(&$this)); + $this->assign_var($varname, $this->parse($handle, true)); + return true; + } + /** + * Concat the uncompiled code for $handle as the value of $varname in the + * root-level. This can be used to effectively include a template in the + * middle of another template. + * + * Note that all desired assignments to the variables in $handle should be + * done BEFORE calling this function. + */ + function concat_var_from_handle($varname, $handle) + { + trigger_action('loc_before_tpl_concat_var_from_handle', $varname, $handle, array(&$this)); + $this->concat_var($varname, $this->parse($handle, true)); return true; } |