Skip to content

Commit

Permalink
support Contao 4.5 news order
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed Jan 11, 2018
1 parent 73a67ff commit 5a42445
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Models/NewsRelatedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,33 @@ public function newsListFetchItems($newsArchives, $blnFeatured, $limit, $offset,
$arrOptions['limit'] = $limit;
$arrOptions['offset'] = $offset;

// fallback to news_sorting (used by news_sorted and news_sorting extension)
$objModule->news_order = $objModule->news_order ?: $objModule->news_sorting;

// support for news_sorted and news_sorting
switch ($objModule->news_sorting)
switch ($objModule->news_order)
{
case 'list_date_asc':
case 'sort_date_asc':
case 'order_date_asc':
$arrOptions['order'] = "$t.date ASC";
break;

case 'list_headline_asc':
case 'sort_headline_asc':
case 'order_headline_asc':
$arrOptions['order'] = "$t.headline ASC";
break;

case 'list_headline_desc':
case 'sort_headline_desc':
case 'order_headline_desc':
$arrOptions['order'] = "$t.headline DESC";
break;

case 'list_random':
case 'sort_random':
case 'order_random':
$arrOptions['order'] = "RAND()";
break;

Expand Down

0 comments on commit 5a42445

Please sign in to comment.