I am generating a list of the latest 4 articles, and want to sort them by date published. This is in order to display the last 4 articles that were published on the site. The problem I am having is that the articles are being displayed in the order determined by the submission_id and not the date published.
This is causing earlier articles to be displayed before later articles, if they have a higher submission_id value.
The code I am using to generate the articles list is as follows:
$request = Application::get()->getRequest();
$journal = $request->getJournal();
import('classes.submission.Submission'); // import STATUS_ constants
//$submissionsIterator = Services::get('submission')->getMany(['contextId' => $journal->getId(), 'status' => STATUS_PUBLISHED, 'count' => RCVSK_LATEST_ARTICLES_DEFAULT]); // this is the original line
$submissionsIterator = Services::get('submission')->getMany(['contextId' => $journal->getId(), 'status' => STATUS_PUBLISHED, 'count' => RCVSK_LATEST_ARTICLES_DEFAULT, 'orderBy' => 'date_published','orderDirection' => 'DESC']); // This is the modified line
$submissionsInSections = [];
foreach ($submissionsIterator as $submission) {
$submissionsInSections[]['articles'][] = $submission;
}
When the articles are being displayed it shows them in the order of submission_id and not date_published.
How would I modify the query so that it actually does grab the latest articles by date_published?
I am using OJS 3.3.0.13 (latest)