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;
}
}
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());
}
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}
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}
You can insert that on this place in the issue_toc.tpl: https://github.com/pkp/ojs/blob/master/templates/frontend/objects/issue_toc.tpl#L92 i.e. directly after {include...
and in that articles foreach
loop. Or for example on this line in article_summary.tpl: https://github.com/pkp/ojs/blob/master/templates/frontend/objects/article_summary.tpl#L70.
I do not understand the error you mentioned, but maybe it will be solved when you change/apply all this…
Best,
Bozana