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.
acahya
October 23, 2025, 8:20am
5
Any Update ? for displaying into the TOC
acahya
November 7, 2025, 2:05am
6
PHP message: PHP Fatal error: Uncaught Error: Call to undefined method APP\submission\Submission::getViews() in /home/www/jom.htp.ac.id/cache/t_compile/ecff5f98702ff1f13016ec56f91cc894676856e4^7cf1cd52b8ba8108de77f197078de34b733dd394_0.app.frontendobjectsarticle_summary.tpl.php:108
I have tried to create an abstract view and download count for OJS 3.5 by making a service plugin to display the data
//The code inserted to article_summary.tpl
{get_article_views id=$article->getId()}
{get_galley_views id=$galley->getId()}
/**
* Register Smarty functions
*/
public function registerSmartyFunctions(string $hookName, array $args): bool
{
$templateMgr = $args[0];
// Register {get_article_views id=...}
$templateMgr->registerPlugin('function', 'get_article_views', function($params, $smarty) {
if (!isset($params['id'])) return 0;
return $this->service->getArticleViews((int) $params['id']);
});
// Register {get_galley_views id=...}
$templateMgr->registerPlugin('function', 'get_galley_views', function($params, $smarty) {
if (!isset($params['id'])) return 0;
return $this->service->getGalleyViews((int) $params['id']);
});
return false;
}
/**
* Get Total Views for an Article
*/
public function getArticleViews($submissionId): int
{
// 1048585 = ASSOC_TYPE_SUBMISSION
return (int) DB::table('metrics_submission')
->where('submission_id', '=', $submissionId)
->where('assoc_type', '=', 1048585)
->sum('metric');
}
/**
* Get Total Views for a Galley
*/
public function getGalleyViews($galleyId): int
{
// Query representation_id for Galley (Galley ID = representation_id)
return (int) DB::table('metrics_submission')
->where('representation_id', '=', $galleyId)
->sum('metric');
}
the result preview
deejournal:
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