Skip to content

Commit eeb8829

Browse files
authored
[6.1] Child templates extend language instead of override (#46353)
1 parent 3a4e569 commit eeb8829

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

libraries/src/Document/HtmlDocument.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,11 +773,14 @@ protected function _fetchTemplate($params = [])
773773
// Load the language file for the template
774774
$lang = CmsFactory::getLanguage();
775775

776+
if ($inherits) {
777+
$lang->load('tpl_' . $inherits, $directory . '/' . $inherits)
778+
|| $lang->load('tpl_' . $inherits, JPATH_BASE);
779+
}
780+
776781
// 1.5 or core then 1.6
777782
$lang->load('tpl_' . $template, JPATH_BASE)
778-
|| ($inherits !== '' && $lang->load('tpl_' . $inherits, JPATH_BASE))
779-
|| $lang->load('tpl_' . $template, $directory . '/' . $template)
780-
|| ($inherits !== '' && $lang->load('tpl_' . $inherits, $directory . '/' . $inherits));
783+
|| $lang->load('tpl_' . $template, $directory . '/' . $template);
781784

782785
// Assign the variables
783786
$this->baseurl = Uri::base(true);

libraries/src/MVC/View/HtmlView.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,16 +367,22 @@ public function loadTemplate($tpl = null)
367367
$file = preg_replace('/[^A-Z0-9_\.-]/i', '', $file);
368368
$tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\.-]/i', '', $tpl) : $tpl;
369369

370-
try {
371-
// Load the language file for the template
372-
$lang = $this->getLanguage();
373-
} catch (\UnexpectedValueException $e) {
374-
$lang = Factory::getApplication()->getLanguage();
375-
}
370+
if (Factory::getApplication()->getDocument()->getType() !== 'html') {
371+
try {
372+
// Load the language file for the template
373+
$lang = $this->getLanguage();
374+
} catch (\UnexpectedValueException $e) {
375+
$lang = Factory::getApplication()->getLanguage();
376+
}
376377

377-
$lang->load('tpl_' . $template->template, JPATH_BASE)
378-
|| $lang->load('tpl_' . $template->parent, JPATH_THEMES . '/' . $template->parent)
379-
|| $lang->load('tpl_' . $template->template, JPATH_THEMES . '/' . $template->template);
378+
if ($template->parent) {
379+
$lang->load('tpl_' . $template->parent, JPATH_THEMES . '/' . $template->parent)
380+
|| $lang->load('tpl_' . $template->parent, JPATH_BASE);
381+
}
382+
383+
$lang->load('tpl_' . $template->template, JPATH_BASE)
384+
|| $lang->load('tpl_' . $template->template, JPATH_THEMES . '/' . $template->template);
385+
}
380386

381387
// Change the template folder if alternative layout is in different template
382388
if (isset($layoutTemplate) && $layoutTemplate !== '_' && $layoutTemplate != $template->template) {

0 commit comments

Comments
 (0)