From 5ee8a5e3409463a6c53c2449c8138f43ef2189a1 Mon Sep 17 00:00:00 2001 From: SharkyKZ Date: Tue, 12 Jun 2018 18:44:45 +0300 Subject: [PATCH 1/2] [mod_tags_similar] Link cleanup --- modules/mod_tags_similar/helper.php | 44 ++++++++++++++--------- modules/mod_tags_similar/tmpl/default.php | 4 +-- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/modules/mod_tags_similar/helper.php b/modules/mod_tags_similar/helper.php index effae0fba923d..b0de1512f3901 100644 --- a/modules/mod_tags_similar/helper.php +++ b/modules/mod_tags_similar/helper.php @@ -11,6 +11,8 @@ use Joomla\Registry\Registry; +JLoader::register('TagsHelperRoute', JPATH_BASE . '/components/com_tags/helpers/route.php'); + /** * Helper for mod_tags_similar * @@ -61,19 +63,19 @@ public static function getList(&$params) $query = $db->getQuery(true) ->select( - array( - $db->quoteName('m.core_content_id'), - $db->quoteName('m.content_item_id'), - $db->quoteName('m.type_alias'), + array( + $db->quoteName('m.core_content_id'), + $db->quoteName('m.content_item_id'), + $db->quoteName('m.type_alias'), 'COUNT( ' . $db->quoteName('tag_id') . ') AS ' . $db->quoteName('count'), - $db->quoteName('ct.router'), - $db->quoteName('cc.core_title'), - $db->quoteName('cc.core_alias'), - $db->quoteName('cc.core_catid'), - $db->quoteName('cc.core_language'), - $db->quoteName('cc.core_params') + $db->quoteName('ct.router'), + $db->quoteName('cc.core_title'), + $db->quoteName('cc.core_alias'), + $db->quoteName('cc.core_catid'), + $db->quoteName('cc.core_language'), + $db->quoteName('cc.core_params'), ) - ); + ); $query->from($db->quoteName('#__contentitem_tag_map', 'm')); @@ -87,14 +89,17 @@ public static function getList(&$params) // Don't show current item $query->where('(' . $db->quoteName('m.content_item_id') . ' <> ' . $id - . ' OR ' . $db->quoteName('m.type_alias') . ' <> ' . $db->quote($prefix) . ')'); + . ' OR ' . $db->quoteName('m.type_alias') . ' <> ' . $db->quote($prefix) . ')' + ); // Only return published tags $query->where($db->quoteName('cc.core_state') . ' = 1 ') ->where('(' . $db->quoteName('cc.core_publish_up') . '=' . $db->quote($nullDate) . ' OR ' - . $db->quoteName('cc.core_publish_up') . '<=' . $db->quote($now) . ')') + . $db->quoteName('cc.core_publish_up') . '<=' . $db->quote($now) . ')' + ) ->where('(' . $db->quoteName('cc.core_publish_down') . '=' . $db->quote($nullDate) . ' OR ' - . $db->quoteName('cc.core_publish_down') . '>=' . $db->quote($now) . ')'); + . $db->quoteName('cc.core_publish_down') . '>=' . $db->quote($now) . ')' + ); // Optionally filter on language $language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all'); @@ -150,9 +155,14 @@ public static function getList(&$params) foreach ($results as $result) { - $explodedAlias = explode('.', $result->type_alias); - $result->link = 'index.php?option=' . $explodedAlias[0] . '&view=' . $explodedAlias[1] - . '&id=' . $result->content_item_id . '-' . $result->core_alias; + $result->link = TagsHelperRoute::getItemRoute( + $result->content_item_id, + $result->core_alias, + $result->core_catid, + $result->core_language, + $result->type_alias, + $result->router + ); $result->core_params = new Registry($result->core_params); } diff --git a/modules/mod_tags_similar/tmpl/default.php b/modules/mod_tags_similar/tmpl/default.php index cc577d0087c9d..e6acfd4bf8679 100644 --- a/modules/mod_tags_similar/tmpl/default.php +++ b/modules/mod_tags_similar/tmpl/default.php @@ -10,7 +10,6 @@ defined('_JEXEC') or die; ?> -