Advertising on article page

Hi, @abraham.john @asmecher @ctgraham We want to show Google Adsense Ads on the article page on our OJS site. For more clarity on the desired place for the same has been attached with this post. Basically, I want to to add Ad code on the desired place.
Pl suggest if there is any such functionality.

Additionally, we want the same placement on the PDF page of the article. Pl suggest.

Thanks in advance.

1 Like

I don’t know of a way to do exactly what you want without custom coding.

With custom coding, you would want to ideally create a new plugin which uses an existing hook, probably Templates::Article::Article::ArticleCoverImage. We did something similar for allowing the Plum Analytics metrics widget to be positioned on the article page:

Alternately, you could directly modify the file https://github.com/pkp/ojs/blob/ojs-dev-2_4/templates/article/article.tpl . Beware of local changes like this in future upgrades, however.

Finally, since I believe the Google Adsense code is just a snippet of HTML, you could place an arbitrary bit of HTML on your page via the Custom Block plugin. I don’t think positioning immediately above the article title is available by default, but see something like the instructions here:

2 Likes

@Sunil_Sharma

Hi Sunil I agree what @ctgraham answered, you must use a plugin and place it on your page. But still if you are looking to hard code the Adsense, then go to /templates/article/article.tpl
Here If you are using payed subscription and you want to show your ad. above it you can paste your code somewhere in line# 18(In my case I have written “Hello World” in this line), or if you don’t have a payed subscription than paste your code in line#41( In my case I have written “Hello World” in this line). Suite yourself to paste your code in any one of these places.

and guess what here is your result.

Please adjust the coding according to your page design, I have used text only “Hello World” to show you here.

About showing the ads inside your pdf I am not getting it, but my code is still showing while I open the pdf file.

4 Likes

@abraham.john Thank you. As expected, I got the damn sure shot solution to the query. I fixed this by using code in #18 as suggested by you, it works on both abstract page as well as on PDF viewer page. Thank you, keep assisting:)

1 Like

Hi @abraham.john and @asmecher.
Can u give an update about the right spot to put the code with the last version of article.tpl?
The code seems very different now, and I don`t want to mess with it.

{**

  • templates/frontend/pages/article.tpl
  • Copyright (c) 2014-2019 Simon Fraser University
  • Copyright (c) 2003-2019 John Willinsky
  • Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
  • @brief Display the page to view an article with all of it’s details.
  • @uses $article Article This article
  • @uses $issue Issue The issue this article is assigned to
  • @uses $section Section The journal section this article is assigned to
  • @uses $journal Journal The journal currently being viewed.
  • @uses $primaryGalleys array List of article galleys that are not supplementary or dependent
  • @uses $supplementaryGalleys array List of article galleys that are supplementary
    *}
    {include file=“frontend/components/header.tpl” pageTitleTranslated=$article->getLocalizedTitle()|escape}
{if $section} {include file="frontend/components/breadcrumbs_article.tpl" currentTitle=$section->getLocalizedTitle()} {else} {include file="frontend/components/breadcrumbs_article.tpl" currentTitleKey="article.article"} {/if}

{* Show article overview *}
{include file=“frontend/objects/article_details.tpl”}

{call_hook name=“Templates::Article::Footer::PageFooter”}

{include file=“frontend/components/footer.tpl”}

This is updated version of ojs for which you are asking your question, my reply was for the older version of ojs.
Anyways in your code line after {/if} (at line#28 in my code editor) please add your adsense code.(it’s a wild guess) it should appear at the runtime.