0

How can I bring the featured articles to the front of the articles array retrieved by the ArticlesModel?

I know I can change the ordering via this line:

$model->setState('list.ordering', $ordering);

But that is for example on the publish up or down string. But how can I bring the featured articles to the front?

Is that possible with the model or do I just need to loop through the array, and manually bring these items to the front?

1

Order by featured column and use descending direction:

$model->setState('list.ordering', 'a.featured');
$model->setState('list.direction', 'DESC');
2
  • Does this also order the rest of the articles on the published date?
    – Huub S
    May 10 at 14:45
  • No. You can use a.featured DESC, a.publish_up DESC for ordering and an empty string for direction (or a.featured DESC, a.publish_up and DESC) to order by featured state and published date. But I wouldn't trust this too much, it could break at some point.
    – Sharky
    May 11 at 5:25
0

You could use filter.featured=1 to select just the filtered articles and then select the non featured articles and combine the arrays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.