Counter on Journal Home page

Hi all,
Is there any way to add a counter on the journal home page?
OJS version is 2.4.8 and I have already added article views ($article->getViews()) in article.tpl.
I think the exact location to add counter to journal home page is in templates/index/journal.tpl, but I think we are not able to call something like $journal->getViews(). Also, I couldn’t find any documentation anywhere.
Thanks in advance for your time.

Hi @mtoreihi,

If you’re just looking for an indicator of activity, I would suggest looking at any of the Javascript-based view counter embeds out there. You wouldn’t want to embed OJS’s stats, though they would be a better indicator of scholarly statistics, because you would need to generate and store them on the per-journal basis you need in order to avoid performance problems when fetching them for every homepage view.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Dear Alec (@asmecher),
I need a hit counter on the front page of every journal. If you mean to use a third-party package, are there any open source packages that you recommend?

Many thanks,
Mehran Toreihi

Hi @mtoreihi

In order to display the journal home page access count/number similar to those article counts you could add this function into the classes/journal/Journal.inc.php:

function getViews() {
$application =& PKPApplication::getApplication();
return $application->getPrimaryMetricByAssoc(ASSOC_TYPE_JOURNAL, $this->getId());
}

and use {$currentJournal->getViews()} in the templates/index/journal.tpl.
These are only the numbers of the journal home page.

Best,
Bozana

1 Like

Dear @bozana,
Thank you so much. Great answer. Worked like a charm. :blush:

Yours faithfully,
Mehran