/** * Function initializes the template of the component. Returns true on success. * * <p>Instansiates the template object and calls it's init function.</p> * <p>Note: component must be inited by initComponent method.</p> * @param string $templatePage * @param string|bool $siteTemplate * @param string $customTemplatePath * @return bool * */ public final function initComponentTemplate($templatePage = "", $siteTemplate = false, $customTemplatePath = "") { if (!$this->__bInited) { return null; } $this->__templatePage = $templatePage; $this->__template = new CBitrixComponentTemplate(); if ($this->__template->Init($this, $siteTemplate, $customTemplatePath)) { return true; } else { return false; } }
/** * По Битрикс-имени шаблона возвращает путь к его файлу * * @param string $name * @return string * @throws \Twig_Error_Loader */ private function getComponentTemplatePath($name) { list($namespace, $component, $template, $file) = explode(':', $name); if (strlen($template) === 0) { $template = ''; } if (strlen($file) === 0) { $file = ''; } $componentName = "{$namespace}:{$component}"; $component = new \CBitrixComponent(); $component->InitComponent($componentName, $template); $component->__templatePage = $file; $obTemplate = new \CBitrixComponentTemplate(); $obTemplate->Init($component); $templatePath = $_SERVER['DOCUMENT_ROOT'] . $obTemplate->GetFile(); if (!file_exists($templatePath)) { throw new \Twig_Error_Loader("Не удалось найти шаблон '{$name}'"); } return $templatePath; }