My joomla version is 3.7.5.
I'm using the similar tags module for dispaying related articles in article view.
Options in module manager are matching tags "all", "half", and "random".
I'm using the "all" option.
It works fine but it's ordering the article list in ascending order (e.x. in category auto shows, it's displaying articles, first from 2012, then from 2013 etc).
I want to change the ordering to descending (by published date). The code in similar tags helper file is:
// Optionally filter on language
$language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
if ($language !== 'all')
{
if ($language === 'current_language')
{
$language = JHelperContent::getCurrentLanguage();
}
$query->where($db->quoteName('cc.core_language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
}
$query->group(
$db->quoteName(
array('m.core_content_id', 'm.content_item_id', 'm.type_alias', 'ct.router', 'cc.core_title',
'cc.core_alias', 'cc.core_catid', 'cc.core_language', 'cc.core_params')
)
);
if ($matchtype === 'all' && $tagCount > 0)
{
$query->having('COUNT( ' . $db->quoteName('tag_id') . ') = ' . $tagCount);
}
elseif ($matchtype === 'half' && $tagCount > 0)
{
$tagCountHalf = ceil($tagCount / 2);
$query->having('COUNT( ' . $db->quoteName('tag_id') . ') >= ' . $tagCountHalf);
}
if ($ordering === 'count' || $ordering === 'countrandom')
{
$query->order($db->quoteName('count') . ' DESC');
}
if ($ordering === 'random' || $ordering === 'countrandom')
{
$query->order($query->Rand());
}
$db->setQuery($query, 0, $maximum);
What change can i do to change the order?
$query->order($db->quoteName('m.content_item_id') . ' DESC');
underif ($matchtype === 'all' && $tagCount > 0) { $query->having('COUNT( ' . $db->quoteName('tag_id') . ') = ' . $tagCount);
and it does the trick.