Adding DOI and download links for issues to the archives listing

Hey, I understand to I can modify templates. I want to modify the OJS3 issueArchive template in such a way that for each issue in the listing the DOI, the Issue Galley download link appears, and the publication date.

The code for the publication date I could easily copy/paste from another template but none of the snippets for the DOI and the Issue Galley seem to work.

Could you provide some lines of code I could copy/paste to make this work?

Hi @Franklinx,

We won’t be able to provide copy/paste code – you’ll need some expertise in PHP and potentially Smarty templates to make changes like those you describe. I can identify the files you’ll need to work with, and if you get stuck, I can potentially provide some guidance. Just to be sure I understand, you want to add the DOI and download link to the listing of issues, correct?

Regards,
Alec Smecher
Public Knowledge Project Team

That is very much correct. :slight_smile:

Hi @Franklinx,

What version of OJS are you using?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alex,

I am using the latest OJS version: 3.0.2.
I have been playing with the three snippets below.
They are doing fine on the issue-toc template:
{* Published date }, { PUb IDs (eg - DOI) }, and { Full-issue galley *}

When the latest issue is displayed on the indexJournal (the frontpage) then
the {* Published date } and the { Full-issue galley } are displayed but not the { PUb IDs (eg - DOI) *}
The indexJournal imports the issue-toc template.

Adding the snippets to the issueArchive template is even less successful.
{* Published date *} is then the only one that displays its content on the issueArchive page.

{* Published date *}
{if $issue->getDatePublished()}

{translate key="submissions.published"}: {$issue->getDatePublished()|date_format:$dateFormatShort}
{/if}

{* PUb IDs (eg - DOI) }
{foreach from=$pubIdPlugins item=pubIdPlugin}
{if $issue->getPublished()}
{assign var=pubId value=$issue->getStoredPubId($pubIdPlugin->getPubIdType())}
{else}
{assign var=pubId value=$pubIdPlugin->getPubId($issue){
Preview pubId *}
{/if}
{if $pubId}
{assign var=“doiUrl” value=$pubIdPlugin->getResolvingURL($currentJournal->getId(), $pubId)|escape}

{$pubIdPlugin->getPubIdDisplayType()|escape}: {if $doiUrl} {$doiUrl} {else} {$pubId} {/if}
{/if} {/foreach}

{* Full-issue galley *}
{if $issueGalleys && $hasAccess}

    {foreach from=$issueGalleys item=galley}
  • {include file="frontend/objects/galley_link.tpl" parent=$issue}
  • {/foreach}
{/if}

Hi @Franklinx,

I think that code is getting garbled in the post. Try using the “code” button to format it. (This forum supports Markdown syntax.)

Regards,
Alec Smecher
Public Knowledge Project Team

	{* Published date *}
	{if $issue->getDatePublished()}
		<div class="published">
			<span class="label">
				{translate key="submissions.published"}:
			</span>
			<span class="value">
				{$issue->getDatePublished()|date_format:$dateFormatShort}
			</span>
		</div>
	{/if}

{* PUb IDs (eg - DOI) *}
	{foreach from=$pubIdPlugins item=pubIdPlugin}
		{if $issue->getPublished()}
			{assign var=pubId value=$issue->getStoredPubId($pubIdPlugin->getPubIdType())}
		{else}
			{assign var=pubId value=$pubIdPlugin->getPubId($issue){* Preview pubId *}
		{/if}
		{if $pubId}
			{assign var="doiUrl" value=$pubIdPlugin->getResolvingURL($currentJournal->getId(), $pubId)|escape}
			<div class="pub_id {$pubIdPlugin->getPubIdType()|escape}">
				<span class="type">
					{$pubIdPlugin->getPubIdDisplayType()|escape}:
				</span>
				<span class="id">
					{if $doiUrl}
						<a href="{$doiUrl|escape}">
							{$doiUrl}
						</a>
					{else}
						{$pubId}
					{/if}
				</span>
			</div>
		{/if}
	{/foreach}

{* Full-issue galley *}
	{if $issueGalleys && $hasAccess}
		<ul class="galleys_links">
			{foreach from=$issueGalleys item=galley}
				<li>
					{include file="frontend/objects/galley_link.tpl" parent=$issue}
				</li>
			{/foreach}
		</ul>
	{/if}

</div>

Hi @Franklinx

I think your template does not know/have the variable $pubIdPlugins. You will have to assign it to the template, either in the pages/index/IndexHandler.inx.php, for example after this line: https://github.com/pkp/ojs/blob/master/pages/index/IndexHandler.inc.php#L65, or in pages/issue/IssueHandler.inc.php, function _setupIssueTemplate:

$pubIdPlugins = PluginRegistry::loadCategory(‘pubIds’, true);
$templateMgr->assign(‘pubIdPlugins’, $pubIdPlugins);

Best,
Bozana

Thanks @bozana,
One part of the problem is solved now. After including:

$pubIdPlugins = PluginRegistry::loadCategory('pubIds', true); $templateMgr->assign('pubIdPlugins', $pubIdPlugins);

in the indexHandler the DOI of the issue appeared on the indexJournal page, the home page of the site. Good!

However, the problem with the issueArchive page persists. This page uses:
{include file="frontend/objects/issue_summary.tpl"}

On the issueSummary template I have included the code I have posted 3 days earlier. Only the publication date appears. The DOI and the Issue Galley don’t.

I checked what happens if I paste the
{include file="frontend/objects/issue_summary.tpl"}
on the indexJournal f. In this case all elements do appear.

Clearly I am missing something here.

Hi @Franklinx

It would then be best to insert those two lines in the function _setupIssueTemplate in pages/issue/IssueHandler.inc.php. Then I think you can also remove it from pages/index/IndexHandler.inx.php.

Best,
Bozana

Dear @bozana adding the two lines to IssueHandler.inc.php had no desired effect but removing them from the IndexHandler.inc.php resulted in a disappearing DOI. So, I did put them back.
I guess it is another inc.php document that rules the issueArchive.tpl
But which?
The two lines seem to address just the ‘Id’ (DOI).
Please not that the Issue Galley doesn’t appear as well on the Archives page.
I was only successful in adding the publication date.

Hi @Franklinx

Ah, sorry, I was wrong – the _setupIssueTemplate is not used for issue archive list :-
You would then need to put those two lines somewhere here: https://github.com/pkp/ojs/blob/master/pages/issue/IssueHandler.inc.php#L135 – that is the function that handles the issue archive list.

I will take a look for the galleys…

Sorry!
Bozana

Hi @Franklinx

Hmmm… To display the issue galleys on the archive page you would need much more code to add/change. You would have to first get all galleys of all issues and then to check that in the template for each issue.
You would need something like this between these two code lines in IssueHandler, https://github.com/pkp/ojs/blob/master/pages/issue/IssueHandler.inc.php#L134-L135:

$issues = $publishedIssuesIterator->toArray();
$issueGalleyDao = DAORegistry::getDAO(‘IssueGalleyDAO’);
$issuesGalleys = array();
foreach ($issues as $issue) {
$issueGalleys = $issueGalleyDao->getByIssueId($issue->getId());
if (!empty($issueGalleys)) $issuesGalleys[$issue->getId()] = $issueGalleys;
}
$templateMgr->assign(‘issuesGalleys’, $issuesGalleys);
$publishedIssuesIterator = $issueDao->getPublishedIssues($journal->getId(), $rangeInfo);
Note that the last line has to be double in that function.

And then in the template something like:

{* Full-issue galley *}
{assign var=hasAccess value=true}
{assign var=issueId value=$issue->getId()}
{assign var=issueGalleys value=$issuesGalleys[$issueId]}
{if $issueGalleys && $hasAccess}


    {foreach from=$issueGalleys item=galley}

  • {include file=“frontend/objects/galley_link.tpl” parent=$issue}

  • {/foreach}

{/if}
Note that here hasAccess is defined to always be true.
In order to get the correct access permissions, you would need to also get all the follwoing information for each issue: https://github.com/pkp/ojs/blob/master/pages/issue/IssueHandler.inc.php#L296-L335 – similarly to the issuesGalleys in IssueHandler::archive – and then to check them all appropriately in the template file.

Best,
Bozana

No problem. Added the code and the DOI appeared. Thanks a lot.

Thanks Bozana, it works. Download link for the issue galley appears together with the DOI on the Issue Archive page.

@asmecher @bozana
Both, there are thousands of OJS installations. I can’t believe we are the only ones that like to have the DOI’s and Issue Galley included like above. Is there any reason not to add these lines of code to the IssueHandler and the IndexHandler?

Frank