diff --git a/src/Template.php b/src/Template.php index d6e52dc..e4f3e7b 100644 --- a/src/Template.php +++ b/src/Template.php @@ -19,7 +19,10 @@ class Template function __construct($folder){ $configFile = $folder.'/config/config.php'; if(p\realpath($configFile)){ - $r=p\l($configFile,_INIT_CONFIG); + $r=p\l( + $configFile, + _INIT_CONFIG + ); $this->_configs =& $r->var[_INIT_CONFIG]; } else { return !trigger_error('Can\'t find theme config file ('.$configFile.')'); @@ -54,5 +57,3 @@ function getFile($tpl_name, $useDefault = true){ } } //end class Template - - diff --git a/src/ViewEngine.php b/src/ViewEngine.php index a3a1d00..17c3041 100644 --- a/src/ViewEngine.php +++ b/src/ViewEngine.php @@ -63,6 +63,7 @@ public function setThemeFolder($val) if (!$this['themeFolder']) { throw new DomainException('Template folder was not found: ['.$val.']'); } + $this->initTemplateHelper(); } /** @@ -139,13 +140,14 @@ public function getTpl() */ public function initTemplateHelper($tpl=null) { - if (!$this->_tpl) { - if (is_null($tpl)) { - $tpl = new Template($this['themeFolder']); - } - $this->_tpl = $tpl; - $this[[]] = $tpl(); //append + if (!empty($this->_tpl)) { + return; } + if (is_null($tpl)) { + $tpl = new Template($this['themeFolder']); + } + $this->_tpl = $tpl; + $this[[]] = $tpl(); //append /** * Copy tpl variables back to plugin config