I registered $GLOBALS['TL_HOOKS']['newsListFetchItems'][] hook in my news extended extension for sorting with my custom field (say 'rank'). But the pages which contain news filtering is not working . I am using the contao Version 4.5.8 . How can I solve the issue.
$t = \NewsModel::getTable();
$arrOptions = array();
switch ($objModule->news_sorting)
{
case 'sort_rankid_asc':
$arrOptions['order'] = "$t.rankid = 0, $t.rankid, $t.date DESC";
break;
case 'sort_random':
$arrOptions['order'] = "$t.date DESC";
break;
default:
$arrOptions['order'] = "$t.date DESC";
}
return \NewsModel::findPublishedByPids($newsArchives, $blnFeatured, $limit, $offset, $arrOptions);
News filtering with category is not working after I added the above code.How Can I fix the issue
The codefog/contao-news_categories
extension in version 3.x
also uses the newsListFetchItems
hook to filter the news list items (see here). The hook will only work for one extension - which ever one returns something other than false
first.
If you need both your custom sorting and filtering by a category, then you will need to implement the news category filtering yourself and you have to make sure that your hook is executed first.