diff --git a/libraries/src/Document/HtmlDocument.php b/libraries/src/Document/HtmlDocument.php index 1cc28b52d6c5c..3e5bf5f538222 100644 --- a/libraries/src/Document/HtmlDocument.php +++ b/libraries/src/Document/HtmlDocument.php @@ -827,22 +827,22 @@ protected function _fetchTemplate($params = array()) $inherits = $params['templateInherits'] ?? ''; $baseDir = $directory . '/' . $template; - if (!empty($inherits) - && !is_file($directory . '/' . $template . '/' . $file) - && is_file($directory . '/' . $inherits . '/' . $file) - ) + if (!is_file($directory . '/' . $template . '/' . $file)) { - $baseDir = $directory . '/' . $inherits; - } - - if (!is_file($baseDir . '/' . $file)) - { - $template = 'system'; - } + if ($inherits !== '' && is_file($directory . '/' . $inherits . '/' . $file)) + { + $baseDir = $directory . '/' . $inherits; + } + else + { + $baseDir = $directory . '/system'; + $template = 'system'; - if (!is_file($baseDir . '/' . $file)) - { - $file = 'index.php'; + if ($file !== 'index.php' && !is_file($baseDir . '/' . $file)) + { + $file = 'index.php'; + } + } } // Load the language file for the template @@ -850,7 +850,7 @@ protected function _fetchTemplate($params = array()) // 1.5 or core then 1.6 $lang->load('tpl_' . $template, JPATH_BASE) - || $lang->load('tpl_' . $inherits, $directory . '/' . $inherits) + || ($inherits !== '' && $lang->load('tpl_' . $inherits, $directory . '/' . $inherits)) || $lang->load('tpl_' . $template, $directory . '/' . $template); // Assign the variables