Hello folks! Recently I faced with my editors’ request to have a better view of the future issue’s table of contents. Working on a ToC with many papers is really difficult, because very often the articles have similar titles and it’s hard to recreate a right order.
I edited just two php files (on OJS 3.3.0-6) to get this list with the author/title view:
I want to share it with the community for three reasons. (a) I’m not a coding expert, so I’d like if someone could check my changes! (b) I hope it can be useful for other users and (c) I want know if it’s a common necessity.
In this case, I’d love if it can become a new feature for next releases. Obviously it would mean that I don’t have to change my code with every update!
Instruction to edit files
To change the Table of Contents, I edited just two files. The first one is /controllers/grid/toc/TocGridHandler.inc.php
. You need to find these lines that managed the unique standard column (about titles)…
// Article title $this->addColumn( new GridColumn( 'title', 'article.title', null, null, $tocGridCellProvider ) );
…and replace them with the following ones. They add a new column with authors; furthermore, they resize both column with an horizontal ratio of 25/75%.
// Article author $this->addColumn( new GridColumn( 'author', 'article.author', null, null, $tocGridCellProvider, ['width' => 24 /*percent*/, 'maxLength' => 25 /*digits*/] ) ); // Article title $this->addColumn( new GridColumn( 'title', 'article.title', null, null, $tocGridCellProvider, ['width' => 74 /*percent*/] ) );
At this moment, you have two columns but the system doesn’t know where it can find the author’s name. So you take the second file /controllers/grid/toc/TocGridCellProvider.inc.php
, now. Search for the following lines.
switch ($columnId) { case 'title': return ['label' => $element->getLocalizedTitle()];
And replace them with these ones, in which I added the case ‘author’ to point at the authors’ names.
switch ($columnId) { case 'author': return array('label' => $element->getShortAuthorString()); case 'title': return array('label' => $element->getLocalizedTitle());
If everything works, now you have a nice double-columned Table of contents, with authors and titles. Unfortunately, the sections titles appear in the first short column and so they are truncated. However I preferred to not edit more files to change them.
(I already shared the code in a github topic, but it was from 2019 so I thought it has no visibility at all today. Sorry if I shouldn’t repost it here too.)