Dear PKP Support Team,
I hope this message finds you well.
I am currently working with OJS 3.5.0.0 and would like to inquire about the best practices or recommended methods to display DOI, abstract view counts, and PDF download statistics directly on each article’s page (e.g., in article_summary.tpl
). While I was able to achieve this customization in OJS 3.3.0.14 by editing IssueHandler.php
and article_summary.tpl
, I’ve found that the same approach no longer works in version 3.5.0.0.
For the DOI, I managed to resolve the issue by copying the relevant code from article_details.tpl
into article_summary.tpl
. However, I am unsure how to retrieve and display the number of abstract views and PDF downloads in the updated version. I would greatly appreciate any guidance, documentation, or code examples related to this.
Please note that I am not a professional developer or programmer. I have only learned a little bit about OJS customization through self-study and trial-and-error while managing our journal. Therefore, any explanation or solution in a simplified or step-by-step manner would be extremely helpful.
Thank you very much for your time and support.
Best regards,
deejournal
Screenshots
1 Like
Please share the code with the community? So we can look into the issue.
I used this code in version 3.3.0-14, and tried it in 3.5.0-0, but it produced no result.
for IssueHandler.php (DOI)
$pubIdPlugins = PluginRegistry::loadCategory(‘pubIds’, true);
$templateMgr->assign(‘pubIdPlugins’, $pubIdPlugins);
for article_summary.tpl (DOI, Abstact Views, PDF Downloads)
{foreach from=$pubIdPlugins item=pubIdPlugin}
{if $issue->getPublished()}
{assign var=pubId value=$article->getStoredPubId($pubIdPlugin->getPubIdType())}
{else}
{assign var=pubId value=$pubIdPlugin->getPubId($article)}{* Preview pubId *}
{/if}
{if $pubId}
{assign var=“doiUrl” value=$pubIdPlugin->getResolvingURL($currentJournal->getId(), $pubId)|escape}
{translate key=“plugins.pubIds.doi.readerDisplayName”} :
{$doiUrl}
{/if}
{/foreach}
{translate key=“article.abstract”} Views: {$article->getViews()} ,
{if is_a($article, ‘PublishedArticle’)}{assign var=galleys value=$article->getGalleys()}{/if}
{if $galleys}
{foreach from=$galleys item=galley name=galleyList}
{$galley->getGalleyLabel()} Downloads: {$galley->getViews()}
{/foreach}
{/if}
tried using this too:
<?php
$metricsDao = \DAORegistry::getDAO('MetricsDAO'); // or 'PKPMetricsDAO'
foreach ($issueSubmissions as $submission) {
$submissionId = $submission->getId();
$contextId = $submission->getData('contextId');
// Abstract views
$abstractViews = 0;
$result = $metricsDao->getMetrics(
'ojs::counter',
['metric'],
[
'assoc_type' => 1048585, // ASSOC_TYPE_SUBMISSION
'assoc_id' => $submissionId,
'context_id' => $contextId,
]
);
if ($result && isset($result[0]['metric'])) {
$abstractViews = (int)$result[0]['metric'];
}
// PDF downloads
$pdfDownloads = 0;
foreach ($submission->getGalleys() as $galley) {
if (method_exists($galley, 'isPdfGalley') && $galley->isPdfGalley()) {
$pdfResult = $metricsDao->getMetrics(
'ojs::counter',
['metric'],
[
'assoc_type' => 1048594, // ASSOC_TYPE_SUBMISSION_FILE
'assoc_id' => $galley->getId(),
'context_id' => $contextId,
]
);
if ($pdfResult && isset($pdfResult[0]['metric'])) {
$pdfDownloads += (int)$pdfResult[0]['metric'];
}
}
}
$submission->getCurrentPublication()->setData('abstractViews', $abstractViews);
$submission->getCurrentPublication()->setData('pdfDownloads', $pdfDownloads);
}
This resulted in an error while loading the page.