Display Current issue cover in custom block

Hi, I have an OJS 2.8 set up currently running on IJMASR. I currently have a custom block on the left that i use to display the cover of latest issue for my journal. I however find it tedious to continually change the cover issue manually every now and then and will rather have the block load the cover for the latest cover issue. How can i get this done and what be the proper code to replace the current one. Here is what the code in the custom block looks like.
<p><a href="/index.php" target="_self"><img class="commonCSS coverIssue" src="/public/site/images/admin/cover_issue_8_en_US.jpg" alt="IJMASR Cover Issue" /></a></p>

I did some digging and found the template for the cover issue and found this block of code that may be vital it doesn’t seem to help. Kindly find the code below.

<div id="commonCSS coverIssue"><a href="/public/journals/1/{$currentUrl}"><img src="/public/journals/1/&quot;{$coverPagePath|escape}{$issue-" alt=" Current Issue Cover page" />getFileName($locale)|escape}"{if $coverPageAltText != ''} alt="{$coverPageAltText|escape}"{else} alt="{translate key="issue.coverPage.altText"}"{/if}{if $width} width="{$width|escape}"{/if}{if $height} height="{$height|escape}"{/if}/&gt;</a></div>

I will appreciate your kind help to get the php code above to refer to the “Current Issue URL” so as to pull up the required info. Thanks. In case i missed it, the custom block displays on the journal home page.

I found some additional code in the Index handler php file and this is what it looks like.
{if $issue && $currentJournal->getSetting('publishingMode') != $smarty.const.PUBLISHING_MODE_NONE} {* Display the table of contents or cover page of the current issue. *} <br /> <h3>{$issue->getIssueIdentification()|strip_unsafe_html|nl2br}</h3> {include file="issue/view.tpl"} {/if}
I have a feeling i could work with this instead but not sure how to alter it to fit and work inside the custom block

Your kind help please @asmecher @bozana @ctgraham

Hi @SelasePKP

You cannot use PHP code in the custom block plugin, just normal HTML. In order to make your block dynamic you will have to implement a new block plugin, containing that code. You can orient yourself on other block plugins for that – they are not so difficult to implement – e.g. the ‘information’ block plugin. (You would use the code above in the ‘block.tpl’. Also, you will have to provide all the necessary variables (e.g. $coverPagePath from above) to that template i.e. all variables used in that code in the function ‘getContents’ of your new block plugin. For that you can see the function ‘_setupIssueTemplate’ in the pages/issue/IssueHandler.inc.php.)

Best,
Bozana

1 Like