I have read your suggestions in this Article statistics showing 0 abstract views and 0 PDF downloads - #2 by bozana
(1)
The code changed in OJS 3.0.1, so it cannot be used as it is. You will have to change the function getViews in classes/article/ArticleGalley.inc.php to be like this:
function getViews() {
$application = PKPApplication::getApplication();
if (!$this->getRemoteURL()) {
return $application->getPrimaryMetricByAssoc(ASSOC_TYPE_SUBMISSION_FILE, $this->getFileId());
} else {
return 0;
}
}
DONE
(2)
Furthermore, there is currently no getViews function for articles. If you want to use it, you will have to add the following function to your classes/article/Article.inc.php:
function getViews() {
$application = PKPApplication::getApplication();
return $application->getPrimaryMetricByAssoc(ASSOC_TYPE_SUBMISSION, $this->getId());
}
I HAVE ADDED IT
For (3) and (4) I don’t understand
(3)
Also, you do not need the line {if is_a($article, ‘PublishedArticle’)}… in article_details.tpl, so there it should be something like:
{translate key="article.abstract"} viewed = {$article->getViews()} times
{if $galleys}
{foreach from=$galleys item=galley name=galleyList}
{$galley->getGalleyLabel()} | {$galley->getViews()} | times
{/foreach}
{/if}
(4)
In issue_toc.tpl (or article_summary.tpl) you would maybe need that line, but not at that place, but rather something like this:
{if is_a($article, 'PublishedArticle')}{assign var=galleys value=$article->getGalleys()}{/if}
{if $galleys}
{foreach from=$galleys item=galley name=galleyList}
{$galley->getGalleyLabel()} | {$galley->getViews()} | times
{/foreach}
{/if}
in article_details.tpl, I don’t find (3) I only find