[OJS3.1.2.0] Archive (front)page: Change ordering of back issues to descending?

Is it possible to change the ordering of the back issues on the archive (front)page from ascending to descending? How can I do that?


if you open the list of backissues (Issues → Backissues) there is an order option on the top right. Then you can drag and drop it how you want it.

Hope that helps!
Best regards,

Thanks, Franzi, I’m aware of that. But we’re soon importing nearly 200 back issues. I need an automatic way of sorting.

As OJS sorts automatically ascending per publishing date, there must be a trick (or code) to do this descending …


If you are comfortable with SQL, you can populate the table custom_issue_orders with an SQL query.

If you want to make a change to the code (not recommended), for most purposes, the default order of publication date descending probably comes from this method:

@ctgraham thanks for pointing this out. I’m a bit surprised, that the SQL statement in #L588 shows a i.date_published DESC.

If I run this statement directly on our database, I get an error for the part i.journal_id = ?. If I delete that part, the SQL output is correct and sorts descending from latest to oldest issue. But the output in the frontend of our OJS is ascending:

Is this a bug? Or what am I missing?

Thanks, Tobias

Ah, I see: parameterized query with (int) $journalId, $rangeInfo.

But basically this SQL statements sorts DESC, but the output is ASC.

Thanks, Tobias

The issue/archive URL now uses the IssueService to get issues:

This passes in the orderDirection of “ASC”.

Thanks @ctgraham. I changed #L132 'ASC' to 'DESC', but nothing happens on the archive page.

Any further suggestions?

Do you have any existing custom issue ordering? I have not checked the code, but I suspect it would override the ordering here, if it exists.

No, the custom_issue_orders table is empty – I checked that.

@ctgraham do you have any further ideas or can you reproduce the behavior of our installation? Thanks!

For me, the default ordering is descending (newest to oldest), and when I change the value of ‘orderDirection’ from ‘DESC’ to ‘ASC’ it switches to oldest to newest.

What theme are you using?

@ctgraham I suspected that. So there is a bug in our (special) installation.

We’re using the default theme with modifications in a separate default-child-theme.

In the default-child-theme we have a slight modification of templates/frontend/pages/issueArchive.tpl, but nothing, that will change sorting behavior:

	<div>{if $supportedLocales.$currentLocale == "Deutsch"}
			Das Archiv der TATuP Jahrgänge 1 (1992) bis 25 (2016) finden Sie unter <a href="http://www.tatup-journal.de/archiv.php" target="_blank">http://www.tatup-journal.de/archiv.php</a>. Wir werden alte Archive in Kürze auf <a href="http://www.tatup.de/" target="_blank">www.tatup.de</a> umziehen.
			For TATuP volumes 1 (1992) to 25 (2016) please visit the archive at <a href="http://www.tatup-journal.de/archiv.php" target="_blank">http://www.tatup-journal.de/archiv.php</a>. We will be moving old archives to <a href="http://www.tatup.de/" target="_blank">www.tatup.de</a> in due course.
		{*translate key="current.noCurrentIssueDesc"*}

I can’t see a place, where I can change the sorting order in the templates.

To change the ordering in the theme, I would expect the template to either change the variable of the foreach or pre-process or post-process the foreach.

You don’t seem to be doing that, so this is a bit baffling.

No, issueArchive.tpl is exactly the core issueArchive.tpl, except for the add-on lines (new lines from ll. 61–67).

I now changed the template in l. 36 to
{foreach from=$issues|@array_reverse item="issue"}
which results in what we want. But it remains a mystery to me, why I have to do this nonetheless …

When I have the time, I’ll try deactivating our child theme, and look, what happens.

Thanks for your kind help, @ctgraham!


Now I’ve done a lot of trying, but the oldest issue, which was added by a XML import as a archived issue, remains on top of the list:

The issue array is clearly sorted by issue [id] ASC, not per [datePublished] DESC.

Changes in pages/issues/IssueHandler.inc.php doen’t seem to have any effect on our installation (we started with 3.0, 3.0.1, 3.0.2, 3.1, until now

Do you have any further hints for me? I’m a bit baffled.

Thanks, Tobias

BTW: In the backend everything is sorted correctly!


Today I played again with the setting in pages/issues/IssueHandler.inc.php and changed the following lines:

131:			'orderBy' => 'datePublished', /* prev: 'seq' */
132:			'orderDirection' => 'DESC',   /* prev: 'ASC' */

Now it’s working! It’s very puzzling to me, that on your installation the archive is per default ordered by datePublished, although the $params define 'seq', and on our installation it only seems to work, if we choose 'datePublished'

Thanks, Tobias

I’m going to guess that because the custom_issue_orders table is empty, the seq parameter is ineffective, and without other instruction, the database is defaulting to row order, which coincidentally for you is reverse publication date, and for me is publication date (probably due to load order).

If this is the case, we need to add a sane fallback so as not to require custom issue ordering for this to work correctly in the core product.

C.f. Issue ordering on the archive page · Issue #4065 · pkp/pkp-lib · GitHub

@ctgraham Wouldn’t it be best, if there is a configurable option in the backend, so the Admin kann choose, how the archive will be sorted automatically (pubDate or Volume/Number etc. plus ASC, DESC)?

Thanks for pointing to the Github issue, that was very informative!

1 Like

@ctgraham As far as I read the code under

correctly, OJS only allows 3 ways of sorting via 'orderBy': lastModified, seq, and datePublished (where the latter is defined as fallback for all input except the former two).

So the base configuration 'seq' in pages/issues/IssueHandler.inc.php should have a fallback to datePublished, when the database table o.seq is empty. I see.

Still I think it best, to give the user the chance to modify the sorting order via backend options.

@twa, do you have a GitHub account? If so, that would be good feedback to share on the GitHub issue.