[OJS 3.1] How to get total galleys downloads count

I want the total galleys counts (including PDF and XML files). Currently I only get only one (whichever is the last in order). So I want the total galleys download count.

Hi @varshilmehta

How do you get this numbers from OJS? Is it from some statistic report in OJS admin?

Regards,
Israel Cefrin
Public Knowledge Project Team

Hi @varshilmehta

This function does that: pkp-lib/PKPUsageStatsPlugin.inc.php at ojs-3_1_0-0 · pkp/pkp-lib · GitHub
It is used for the usage statistics graph, just that the graph only displays the numbers for the current year: pkp-lib/UsageStatsFrontendHandler.js at ojs-3_1_0-0 · pkp/pkp-lib · GitHub

Else, you can also calculate it by your self, adding the single numbers together.

Or, if you do not need it programmatically, you can get the numbers from the statistics reports.

Best,
Bozana

1 Like

Thanks. What code should I put in the template? like getViews

You would need to provide them either somehow from the plugin (s. this function: https://github.com/pkp/ojs/blob/master/plugins/generic/usageStats/UsageStatsPlugin.inc.php#L51) or from the ArticleHandler.
The easiest way would maybe be to calculate the number by addition of the single galley counts…

Okay, Is it possible to add the variables on the site itself? i am sorry I have very limited knowledge about these things. This is the code what I have entered in the template. This is the last thing left to complete my journal. I will take a big vacation then. lol.

{if $galleys}
{foreach from=$galleys item=galley name=galleyList}
{$galley->getGalleyLabel()}{$galley->getViews()}
{/foreach}
{/if}

Hi @varshilmehta

Your code could then, for example, look something like this:

{if $galleys}
{assign var="galleysTotalView" value=0}
{foreach from=$galleys item=galley name=galleyList}
{$galley->getGalleyLabel()}{$galley->getViews()}
{assign var="galleysTotalView" value=$galleysTotalView+$galley->getViews()}
{/foreach}
<p>Total views: {$galleysTotalView}</p>
{/if}
1 Like

Awesome. It worked :slight_smile:

en que fichero se debe escribir el codigo, porque aun no encuentro en cual va este ultimo codigo aportado por bozana