[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?

Thanks,
Tobias

Hey,
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,
Franzi

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 ā€¦

Tobias

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:
http://www.tatup.de/index.php/tatup/issue/archive

Is this a bug? Or what am I missing?

Thanks, Tobias

@ctgraham
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.
		{else}
			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.
		{/if}
		{*translate key="current.noCurrentIssueDesc"*}
	</div>

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!
Tobias

@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:
http://www.tatup.de/index.php/tatup/issue/archive

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 3.1.2.0).

Do you have any further hints for me? Iā€™m a bit baffled.

Thanks, Tobias

BTW: In the backend everything is sorted correctly!

@ctgraham

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.