Skip to content

Commit

Permalink
[4.0] Fall back to system template when template file not found (joom…
Browse files Browse the repository at this point in the history
…la#30857)

* Fall back to system template

* Load parent language file only when needed

* Correct template file
  • Loading branch information
SharkyKZ authored and sakiss committed Oct 16, 2020
1 parent fdd11c5 commit 917a92c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions libraries/src/Document/HtmlDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,30 +827,30 @@ 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
$lang = CmsFactory::getLanguage();

// 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
Expand Down

0 comments on commit 917a92c

Please sign in to comment.