From 925c4518d686eb0f33993baf12fd69c80688fc27 Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Thu, 28 Oct 2021 12:18:17 +0700 Subject: [PATCH] Improve item parameters merging code --- .../com_weblinks/src/View/Category/HtmlView.php | 13 +++++-------- .../com_weblinks/src/View/Weblink/HtmlView.php | 4 ++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/com_weblinks/src/View/Category/HtmlView.php b/src/components/com_weblinks/src/View/Category/HtmlView.php index d7eacf2..01c5e79 100644 --- a/src/components/com_weblinks/src/View/Category/HtmlView.php +++ b/src/components/com_weblinks/src/View/Category/HtmlView.php @@ -12,7 +12,6 @@ namespace Joomla\Component\Weblinks\Site\View\Category; use Joomla\CMS\MVC\View\CategoryView; use Joomla\CMS\Router\Route; use Joomla\Component\Weblinks\Site\Helper\RouteHelper; -use Joomla\Registry\Registry; defined('_JEXEC') or die; @@ -44,9 +43,12 @@ class HtmlView extends CategoryView // Compute the weblink slug & link url. foreach ($this->items as $item) { - $item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; + $item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; + $temp = $item->params; + $item->params = clone $this->params; + $item->params->merge($temp); - if ($item->params->get('count_clicks', $this->params->get('count_clicks', 1)) == 1) + if ($item->params->get('count_clicks', 1) == 1) { $item->link = Route::_('index.php?option=com_weblinks&task=weblink.go&id=' . $item->id); } @@ -54,11 +56,6 @@ class HtmlView extends CategoryView { $item->link = $item->url; } - - $temp = new Registry; - $temp->loadString($item->params); - $item->params = clone $this->params; - $item->params->merge($temp); } return parent::display($tpl); diff --git a/src/components/com_weblinks/src/View/Weblink/HtmlView.php b/src/components/com_weblinks/src/View/Weblink/HtmlView.php index f524c1b..3a05ff3 100644 --- a/src/components/com_weblinks/src/View/Weblink/HtmlView.php +++ b/src/components/com_weblinks/src/View/Weblink/HtmlView.php @@ -65,6 +65,10 @@ class HtmlView extends BaseHtmlView $item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; + $temp = $item->params; + $item->params = clone $app->getParams(); + $item->params->merge($temp); + $offset = $this->state->get('list.offset'); $app->triggerEvent('onContentPrepare', array('com_weblinks.weblink', &$item, &$item->params, $offset));