Elxis CMS Forum
Support => General => Topic started by: xmanhattan on December 06, 2015, 17:12:43
-
Hello all,
I have implemented some google advertising on my website and would like to ask the following:
How can I embed a block for advertising in between the blogs?
Is anyone using the adsense custom search and is it worth trying to embed that code into the internal site search?
-
I solved this and offer the following for anyone else who is wondering how to do it.
A simple guide of how to insert Google Adsense advertising into your eblog.
To insert Google Adsense advertising into your eblog:
copy /components/com_eblog/eblog.html.php to your local system, if you do not have a copy available.
Also make a backup copy in case you make a mistake.
Open your browser and go to adsense to get your AdSense Publisher ID and the data-ad-slot.
You get these 2 pieces of information from:
Content -> Ad Unit -> New Ad Unit
Give it a name, e.g. MyAds-01, MyAds-02, MyAds-03, etc.
After you have set the parameters for the advertisement to be displayed and saved it, you will be able to get the code for the 2 parameters below. copy the code a window of your editor.
In the code below, change the lines shown:
data-ad-client="ca-pub-12345" the ca-pub-12345 with your AdSense Publisher ID
data-ad-slot="xxxxx" the xxxxx with the numbers from your code.
Edit eblog.html.php and go to line 236 and hit enter 2 or 3 times to make some space for the code below.
<!-- advertising begin -->
<br />
<!-- unit-# -->
<p style="padding: 0.5em 0em; text-align: center;">
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-12345"
data-ad-slot="xxxxx"
data-ad-format="auto"></ins>
</p>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<br />
<!-- advertising end -->
In the code above I have added the <p> tags and styling, you can change it or remove them.
It is assumed that you have an adsense account. If not, sign up if you wish to provide advertisements.
To be a provider of advertisements for adsense, and/or other agencies, you must add some code to
the index.php file of the template that you use.
The following code is inserted just after the <body>
tag.
<!-- google adsense -->
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
That's it.