File download counter in OJS 3

Who can help me create a button, counter for calculating the downloads of a document on the magazine’s website.
Something like in the picture.Screenshot_3

See this thread for one option:

Hello
the solution needs to hard code the template file : article_summary.inc.php (you need to add somme code lines here) if you want these statistics to show on the Table of contents…
See this video for the detailed solution : #OJS Tutorial Menampilkan Abstract and Download Statistics pada Table of Content OJS 3 - YouTube

Hi,
In this video, the code is not visible completely.
I would appreciate it if you can assist in having this code completely.
image

{assign var=galleys value=$article->getGalleys()}
Views: {$article->getViews()}
{if $galleys}
    {foreach from=$galleys item=galley name=galleyList}
       / Download: {$galley->getViews()}
    {/foreach}
{/if}

Hi,
I applied this but it didn’t work:

			</li>
		{/foreach}
	</ul>
{/if}

{call_hook name="Templates::Issue::Issue::Article"}

{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()} Views: {$article->getViews()}
{if $galleys}
{foreach from=$galleys item=galley name=galleyList}
{$galley->getGalleyLabel()} Downloads: {$galley->getViews()}
{/foreach}
{/if}

Add following code to article_details.tpl

templates/frontend/objects/article_details.tpl

{assign var=galleys value=$article->getGalleys()}
Görüntüleme: {$article->getViews()}
{if $galleys}
    {foreach from=$galleys item=galley name=galleyList}
       / İndirme: {$galley->getViews()}
    {/foreach}
{/if}

You can see sample here
https://ojsdergi.com/demo/index.php/dergi/article/view/7

1 Like

Thanks a lot, it worked.

1 Like

A post was split to a new topic: Downloads and views not displaying

Hi, can you help me to add this code in indexJournal.tpl page?
Eg: https://ojsdergi.com/demo/index.php/dergi/index

Want to add this to the article list?

I have successfully implemented on Current issue page. But I want to add this indexJournal.tpl page means journal homepage too?

I added this code only in templates/frontend/objects/article_summary.tpl page.
it is enough to show on the issues page and homepage.

I am using the default theme. It’s only showing in current archive page but not inside the homepage. Any solutions?

I am also using the default theme.

1. I have added this code in templates/frontend/objects/article_summary.tpl

   	{assign var=galleys value=$article->getGalleys()}
<img src="https://ojsdergi.com/ojsicons/gor.png"> <b>{translate key="makale.goruntuleme.sayisi"}:</b> {$article->getViews()}

{if $galleys}
    {foreach from=$galleys item=galley name=galleyList}
       / <img src="https://ojsdergi.com/ojsicons/pdf.png"> <b>{translate key="makale.indirme.sayisi"}:</b> {$galley->getViews()}
    {/foreach}
{/if}

image

2. I have added the following codes to the language file for translation.
locale/en_US/locale.po


msgid "makale.goruntuleme.sayisi"
msgstr "Abstract views"

msgid "makale.indirme.sayisi"
msgstr "PDF downloads"

Thanks brother, It’s working now.

1 Like