Skip to content

Commit

Permalink
Update site.php
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeforJoomla Boy authored Jan 27, 2017
1 parent fb66473 commit 33ffdfa
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions libraries/cms/application/site.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,13 @@ public function getTemplate($params = false)
$tag = '';
}

if (!$templates = $cache->get('templates0' . $tag))
$cacheId = 'templates0' . $tag;

if ($cache->contains($cacheId))
{
$templates = $cache->get($cacheId);
}
else
{
// Load styles
$db = JFactory::getDbo();
Expand All @@ -482,23 +488,25 @@ public function getTemplate($params = false)

foreach ($templates as &$template)
{
$registry = new Registry;
$registry->loadString($template->params);
$template->params = $registry;

// Create home element
if ($template->home == 1 && !isset($templates[0]) || $this->_language_filter && $template->home == $tag)
if ($template->home == 1 && !isset($template_home) || $this->_language_filter && $template->home == $tag)
{
$templates[0] = clone $template;
$template_home = clone $template;
}

$template->params = new Registry($template->params);
}

// Add home element, after loop to avoid double execution
if (isset($template_home))
{
$template_home->params = new Registry($template_home->params);
$templates[0] = $template_home;
}

$cache->store($templates, 'templates0' . $tag);
$cache->store($templates, $cacheId);
}

// Unset the $template reference to the last $templates[n] item cycled in the foreach above to avoid to edit the $templates array in the following assignment
unset($template);

if (isset($templates[$id]))
{
$template = $templates[$id];
Expand Down

0 comments on commit 33ffdfa

Please sign in to comment.