/** * Execute output html using a layout template * * @return string */ protected function renderTemplateWithLayout() { ob_start(); extract($this->_vars); $dir = PathManager::getViewTemplateDirectory(); $ext = NameManager::getTemplateExtension(); $templatePath = sprintf('%s/%s.%s', $dir, $this->_template, $ext); if (!file_exists($templatePath)) { throw new FileNotExistException($templatePath); } require_once $templatePath; $inner_contents = ob_get_contents(); ob_clean(); $dir = PathManager::getViewLayoutDirectory(); $layoutPath = sprintf('%s/%s.%s', $dir, $this->_layout, $ext); if (!file_exists($layoutPath)) { throw new FileNotExistException($layoutPath); } require_once $layoutPath; return ob_get_clean(); }
/** * Execute output html using a layout template * * @return string */ protected function renderTemplateWithLayout() { foreach ($this->_vars as $key => $val) { $this->_smarty->assign($key, $val); } $ext = NameManager::getTemplateExtension(); $templateDir = PathManager::getViewTemplateDirectory(); $template = $this->_template . '.' . $ext; $templatePath = $templateDir . '/' . $template; if (!file_exists($templatePath)) { throw new FileNotExistException($templatePath); } $layoutDir = PathManager::getViewLayoutDirectory(); $layout = $this->_layout . '.' . $ext; $layoutPath = $layoutDir . '/' . $layout; if (!file_exists($layoutPath)) { throw new FileNotExistException($layoutPath); } $this->_smarty->template_dir = $templateDir; $contents = $this->_smarty->fetch($template); $this->_smarty->assign('inner_contents', $contents); $this->_smarty->template_dir = $layoutDir; $rendered = $this->_smarty->fetch($layout); return $rendered; }