[OJS3] HELP: Insert Adsense Code in .tpl


I have tried to insert Google Adsense code into the “templates/frontend/pages/article.tpl" file to show ads in all journal articles.

However, all articles show now a blank page.

If someone can offer me any help, the complete code is:

 * templates/frontend/pages/article.tpl
 * Copyright (c) 2014-2016 Simon Fraser University Library
 * Copyright (c) 2003-2016 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.
{include file="frontend/components/header.tpl" pageTitleTranslated=$article->getLocalizedTitle()|escape}

<div class="page page_article">
	{if $section}
		{include file="frontend/components/breadcrumbs_article.tpl" currentTitle=$section->getLocalizedTitle()}
		{include file="frontend/components/breadcrumbs_article.tpl" currentTitleKey="article.article"}
    {* Google Adsense *}
        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
        <ins class="adsbygoogle"
        (adsbygoogle = window.adsbygoogle || []).push({});

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

	{* Display Dublin Core metadata *}
	{include file="frontend/objects/article_dublinCore.tpl" article=$article}
	{include file="frontend/objects/article_googleScholar.tpl" article=$article}

	{call_hook name="Templates::Article::Footer::PageFooter"}

</div><!-- .page -->

{include file="frontend/components/footer.tpl"}

Hi @Ayax,

Have you checked your PHP error log, and that the file permissions in cache/t_compile permit OJS to administer the files there?

Alec Smecher
Public Knowledge Project Team

Hi @asmecher

At this moment, I cannot view my PHP error log. Can you show me what permissions should have the directory cache/t_compile and how to change it?

Thanks a lot.

Hi @Ayax,

You’ll definitely need to get access to your PHP error log – debugging without it will be very difficult.

For file permissions, check out this FAQ entry.

Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

I have found the php error log directory empty (I checked the php.ini to find out how to locate it) so I’m not sure how to proceed now.

Any suggestion?

PS. Merry Xmas

Hi @Ayax,

Merry Christmas to you too! Did you check into file permissions? If OJS can’t compile your template into cache/t_compile, it’ll have trouble.

Alec Smecher
Public Knowledge Project Team

1 Like

Hi @asmecher,
How can we remove the adverts appearing on heading section of our journal pages? see: ijor.tplondon.com
Thanks for help.

Hi @tplondon,

Those ads are a result of a modification on your installation, so without knowing exactly what’s been done there, I’m not sure!

Alec Smecher
Public Knowledge Project Team