diff options
author | patdenice <patdenice@piwigo.org> | 2008-10-11 12:55:43 +0000 |
---|---|---|
committer | patdenice <patdenice@piwigo.org> | 2008-10-11 12:55:43 +0000 |
commit | 4fbe0ef6669e1df16b1c4a65b2cb10abada4070e (patch) | |
tree | 1b721725eb00699461e636c4edd4b0c3761600ed /include | |
parent | 9d88e93a99a9e291b5eb4e7b5d768770f662a19e (diff) |
- Add known_template function (maybe we can change function name).
- Template extensions are working with menubar blocks templates.
git-svn-id: http://piwigo.org/svn/trunk@2712 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/template.class.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/template.class.php b/include/template.class.php index 0b4b3a404..d99f7ebca 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -66,6 +66,7 @@ class Template { $this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') ); $this->smarty->register_block('html_head', array(&$this, 'block_html_head') ); $this->smarty->register_function('known_script', array(&$this, 'func_known_script') ); + $this->smarty->register_function('known_template', array(&$this, 'func_known_template') ); $this->smarty->register_prefilter( array('Template', 'prefilter_white_space') ); if ( $conf['compiled_template_cache_language'] ) { @@ -408,6 +409,34 @@ class Template { } } + /** + * This smarty "known_template" functions allows to include template + * If extent[$params['id']] exists, include template extension + * else include $params[$file] + */ + function func_known_template($params, &$smarty ) + { + if (!isset($params['file'])) + { + $smarty->trigger_error("known_template: missing 'file' parameter"); + return; + } + + if (isset($params['id']) and isset($this->extents[$params['id']])) + { + $file = $this->extents[$params['id']]; + } + else + { + $file = $params['file']; + } + + return $smarty->_smarty_include(array( + 'smarty_include_tpl_file' => $file, + 'smarty_include_vars' => array() + )); + } + static function prefilter_white_space($source, &$smarty) { $ld = $smarty->left_delimiter; |