Skip to content

Commit

Permalink
Added missing sort order to tagged news lists
Browse files Browse the repository at this point in the history
  • Loading branch information
hschottm committed Dec 2, 2024
1 parent e0a4bbc commit 5aa8faf
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/Resources/contao/modules/ModuleNewsListTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Contao\ModuleNewsList;
use Contao\Database;
use Contao\Input;
use Contao\TagsModel;
use Contao\NewsModel;
use Contao\Environment;
use Contao\Pagination;
use Contao\Config;
Expand Down Expand Up @@ -130,6 +130,36 @@ protected function compileFromParent($arrIds)
$this->Template->pagination = $objPagination->generate("\n ");
}

$t = NewsModel::getTable();
$order = '';

if ($this->news_featured == 'featured_first')
{
$order .= "$t.featured DESC, ";
}

switch ($this->news_order)
{
case 'order_headline_asc':
$order .= "$t.headline";
break;

case 'order_headline_desc':
$order .= "$t.headline DESC";
break;

case 'order_random':
$order .= "RAND()";
break;

case 'order_date_asc':
$order .= "$t.date";
break;

default:
$order .= "$t.date DESC";
}

$objArticles = TagsNewsModel::findPublishedByPidsAndIds($this->news_archives, $arrIds, $blnFeatured, $limit ?: 0, $offset, array('order'=>$order));

// Add the articles
Expand Down

0 comments on commit 5aa8faf

Please sign in to comment.