Skip to content

Commit

Permalink
Code simplify (#32538)
Browse files Browse the repository at this point in the history
  • Loading branch information
joomdonation authored Mar 10, 2021
1 parent b11e957 commit 0220b8b
Showing 1 changed file with 19 additions and 33 deletions.
52 changes: 19 additions & 33 deletions components/com_content/src/View/Article/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,47 +126,33 @@ public function display($tpl = null)
$active = $app->getMenu()->getActive();
$temp = clone $this->params;

// Check to see which parameters should take priority
if ($active)
// Check to see which parameters should take priority. If the active menu item link to the current article, then
// the menu item params take priority
if ($active
&& $active->component == 'com_content'
&& isset($active->query['view'], $active->query['id'])
&& $active->query['view'] == 'article'
&& $active->query['id'] == $item->id)
{
$currentLink = $active->link;

// If the current view is the active item and an article view for this article, then the menu item params take priority
if (strpos($currentLink, 'view=article') && strpos($currentLink, '&id=' . (string) $item->id))
// Load layout from active query (in case it is an alternative menu item)
if (isset($active->query['layout']))
{
// Load layout from active query (in case it is an alternative menu item)
if (isset($active->query['layout']))
{
$this->setLayout($active->query['layout']);
}
// Check for alternative layout of article
elseif ($layout = $item->params->get('article_layout'))
{
$this->setLayout($layout);
}

// $item->params are the article params, $temp are the menu item params
// Merge so that the menu item params take priority
$item->params->merge($temp);
$this->setLayout($active->query['layout']);
}
else
// Check for alternative layout of article
elseif ($layout = $item->params->get('article_layout'))
{
// Current view is not a single article, so the article params take priority here
// Merge the menu item params with the article params so that the article params take priority
$temp->merge($item->params);
$item->params = $temp;

// Check for alternative layouts (since we are not in a single-article menu item)
// Single-article menu item layout takes priority over alt layout for an article
if ($layout = $item->params->get('article_layout'))
{
$this->setLayout($layout);
}
$this->setLayout($layout);
}

// $item->params are the article params, $temp are the menu item params
// Merge so that the menu item params take priority
$item->params->merge($temp);
}
else
{
// Merge so that article params take priority
// The active menu item is not linked to this article, so the article params take priority here
// Merge the menu item params with the article params so that the article params take priority
$temp->merge($item->params);
$item->params = $temp;

Expand Down

0 comments on commit 0220b8b

Please sign in to comment.