diff --git a/components/com_content/src/View/Article/HtmlView.php b/components/com_content/src/View/Article/HtmlView.php index b29f6ceb50d4c..9ed4f4e3cb343 100644 --- a/components/com_content/src/View/Article/HtmlView.php +++ b/components/com_content/src/View/Article/HtmlView.php @@ -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;