fix Определение шаблона

This commit is contained in:
origami11@yandex.ru 2022-09-30 16:21:42 +03:00
parent 282fff8276
commit fdc13fd6be

View file

@ -98,7 +98,8 @@ class Controller_Component
$selected = null;
foreach ($this->viewPath as $index => $viewPath) {
// Загружать шаблон по умолчанию если не найден текущий
if(is_dir(Path::join($this->viewPath[$index], 'templates', $template))) {
$dir = Path::join($this->viewPath[$index], 'templates', $template);
if(is_dir($dir)) {
$tpl = new PHPTAL(Path::join($this->viewPath[$index], 'templates', $template, $name));
$tpl->setPhpCodeDestination(PHPTAL_PHP_CODE_DESTINATION);
$selected = $index;
@ -107,10 +108,11 @@ class Controller_Component
}
if ($selected === null) {
$tpl = new PHPTAL(Path::join($this->viewPath[0], 'templates', 'modern', $name));
// Последний вариант viewPath, путь к папке компонента
$selected = count($this->viewPath) - 1;
$tpl = new PHPTAL(Path::join($this->viewPath[$selected], 'templates', 'modern', $name));
$tpl->setPhpCodeDestination(PHPTAL_PHP_CODE_DESTINATION);
$template = 'modern';
$selected = 0;
}
$tpl->stripComments(true);