[OJS 3.3.0.13] Show thumbnail in issue archives page

Hello everyone!
I would need to show the magazine cover, uploaded in the journal thumbnail, in: Website → Appearance → Setup

Schermata 2022-11-07 alle 13.51.49

and show it next to the file title on the issue archives page:

Schermata 2022-11-07 alle 13.52.48

Is there any way? I tried to figure it out but couldn’t find anything, can you help me?
Thanks for your support

Tiziano

Hi @Tiziano,

Are you using one of the pre-existing OJS themes for your journal? If so, which one?

-Roger
PKP Team

You would have to change the template for the issue archive.

But there is a better way: For each issue, you could upload the thumbnail image as a cover image in the Issue Data tab of your Issue Management. See https://docs.pkp.sfu.ca/learning-ojs/en/production-publication#create-issue

1 Like

Dear @rcgillis and @mpbraendle ,
thank you for your response, yes I am aware that you can upload the image via the issue metadata, but since we have many magazines with dozens of issues, instead of doing them by hand one by one, in the “issue_summery.tpl” page I applied a {if}, this:

{if $issueCover}
		<a class="cover" href="{url op="view" path=$issue->getBestIssueId()}">
			<img src="{$issueCover|escape}" alt="{$issue->getLocalizedCoverImageAltText()|escape|default:''}">
		</a>
	{else}
		{foreach from=$journals item=journal}
			{capture assign="url"}{url journal=$journal->getPath()}{/capture}
			{assign var="thumb" value=$journal->getLocalizedData('journalThumbnail')}
			{if $thumb}
				<a class="cover" href="{url op="view" path=$issue->getBestIssueId()}">
					<img src="{$journalFilesPath}{$journal->getId()}/{$thumb.uploadName|escape:"url"}">
				</a>
			{/if}
		{/foreach}
		
	{/if}

where if you upload the image in the metadata it will display that, instead if it is not there it will display the image I upload in the thumbnail, that was the idea :slight_smile:

But the code doesn’t work because it doesn’t display anything to me, where am I wrong, can you help me?

Thanks
Bye
Tiziano

Yes, I am using the Manuscript (Default child theme).

The variable $journals is not defined - you need to pass it to the template by the calling class (pass to issueArchive.tpl and trickle down to issue_summary.tpl). And you can pass only the journal in question, foreach loop isn’t required.

maybe you can also get $journal by a method call on $issue, if $issue is an object

I’m not familiar with OOP, could you explain more by giving an example?

In the template, you can debug the variable $issue by outputting it with

<pre>{$issue|@var_dump}</pre>

Then you will see that the journal id is stored in an array element with key journalId - good so, it is there.

In your template, several methods are called using $issue, e.g. $issue->getBestIssueId()

You can search now getBestIssueId using a recursive grep to find the corresponding issue class (starting from your ojs root directory):

grep --exclude-dir cache -R "function getBestIssueId" *

and find the function in classes/issue/Issue.inc.php

Inspection of classes/issue/Issue.inc.php reveals that there is a function getJournalId().

So in the Smarty template, you can use $issue->getJournalId() and store it in a variable.
The rest should be easy.

1 Like

Hi @mpbraendle, you were very clear and I followed your explanation and found what I need, if I debug the variable $journals in the file “indexSite.tpl” located in templates → frontend → pages the part I am interested in is this:

["journalThumbnail"]=>
      array(1) {
        ["it_IT"]=>
        array(6) {
          ["name"]=>
          string(18) "minicover_boll.jpg"
          ["uploadName"]=>
          string(26) "journalThumbnail_it_IT.jpg"
          ["width"]=>
          int(187)
          ["height"]=>
          int(250)
          ["dateUploaded"]=>
          string(19) "2022-11-04 10:58:23"
          ["altText"]=>
          string(0) ""
        }
      }

however, if I apply this code in the file “issue_summary.tpl”:

{foreach from=$journals item=journal}
			{assign var="thumb" value=$journal->getLocalizedData('journalThumbnail')}
			{if $thumb}
				<a class="cover" href="{url op="view" path=$issue->getBestIssueId()}">
					<img src="{$baseUrl}/public/journals/{$issue->getJournalId()}/{$thumb.uploadName''}">
				</a>
			{/if}
		{/foreach}

It doesn’t give me error but it doesn’t display anything, am I missing steps surely?
What do you say?

Hi @Tiziano -The {foreach from=$journals item=journal} loop is not needed. As said, $journals is not defined. You need to rethink your code.