Elxis CMS Forum

Support => Elxis 4.x/5.x DEV => Topic started by: michalis1984 on October 05, 2012, 16:19:05

Title: Advertisments module and adsense problem [solved]
Post by: michalis1984 on October 05, 2012, 16:19:05
Advertisments module does not work with adsense. I paste adsense code and the ads does not appear at the site. When i view the source at the live website i see the adsense code like this..

Code: [Select]
                <div class="module">
<script type="text/javascript"><!--
<br />google_ad_client = "ca-pub-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
<br />/* glwsses.gr - Right Top Adv */
<br />google_ad_slot = "xxxxxxxxxxxxx";
<br />google_ad_width = 120;
<br />google_ad_height = 600;
<br />//-->
<br /></script>
<br /><script type="text/javascript"
<br />src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
<br /></script></div>


So, something adds <br /> tag at each line and this breaks the google ads.
Title: Re: Advertisments module and adsense problem
Post by: StefanSultanov on October 07, 2012, 19:30:13
I have the similar issue.
However instead of "<br />" tags it breaks the script with "///////////" characters here and there.
 ???
Title: Re: Advertisments module and adsense problem
Post by: rentasite on October 07, 2012, 22:15:41

Hmm! This is quite interesting...  :o
Title: Re: Advertisments module and adsense problem
Post by: datahell on October 07, 2012, 23:47:56
Write the ad-sense code in one line and it will work!

<script type="text/javascript">google_ad_client = "ca-pub-xxx"; google_ad_slot = "xxx"; ...</script>
Title: Re: Advertisments module and adsense problem
Post by: StefanSultanov on November 03, 2012, 17:27:09
Nope!

Quote
<script type=\\\"text/javascript\\\"><!--google_ad_client = \\\"ca-pub-5078467753617240\\\";/* v728x90 */google_ad_slot = \\\"3819279798\\\";google_ad_width = 728;google_ad_height = 90;//--></script><script type=\\\"text/javascript\\\"src=\\\"http://pagead2.googlesyndication.com/pagead/show_ads.js\\\"></script>

As you can see, something weird is happening to my code.
It never worked as you suggested. I thought I should wait for the advertisement elements to become active.

What to do?
Is this something related to quotes characters?
Title: Re: Advertisments module and adsense problem
Post by: datahell on November 03, 2012, 18:45:15
This is the clean code (write it in one line):
<script type="text/javascript">
google_ad_client = 'ca-pub-5078467753617240'; google_ad_slot = '3819279798'; google_ad_width = 728; google_ad_height = 90;
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

As for the quotes I guess you must disable magic quotes (http://php.net/manual/en/security.magicquotes.php) (which is OK as they are deprecated).
Title: Re: Advertisments module and adsense problem
Post by: StefanSultanov on November 03, 2012, 20:36:13
magic_quotes_gpc are set to OFF
But I noticed a slight difference from your code to the way I get it from google.
I corrected the code and it works.

Brilliant!!!
Thank you!

@michalis1984 Should we mark this [Solved]?