Responsive AdSense

Responsive AdSense

That's been in the main FAQ for almost three years ;)

How can I find out which template to edit?
Using your browser, view the page source and look for a line of code near the top of the page which begins
<div id="content" class="; the class is the name of the template. So for the main forum page, the line of code is: <div id="content" class="forum_list">, which makes the template forum_list.

[url]http://xenforo.com/community/threads/frequently-asked-questions.5183/#post-181112[/URL]
 
That's been in the main FAQ for almost three years ;)

How can I find out which template to edit?
Using your browser, view the page source and look for a line of code near the top of the page which begins
<div id="content" class="; the class is the name of the template. So for the main forum page, the line of code is: <div id="content" class="forum_list">, which makes the template forum_list.

http://xenforo.com/community/threads/frequently-asked-questions.5183/#post-181112
:oops: ... I think ill just bookmark that page for future.
 
I use another script to show my ads, but I also want to prevent showing ads on error pages and other pages against the TOS
so I included Brogan his line of code into my script.

HTML:
<xen:if is="!in_array({$contentTemplate}, array('', 'message_page', 'error', 'search_form', 'search_form_post', 'search_form_profile_post', 'search_results', 'register_form', 'login', 'error_with_login', 'contact'))">
</xen:if>

My script was working perfect without that line of code, but when i add that line it's not working anymore. o_O

This is my script

HTML:
<xen:if is="!in_array({$contentTemplate}, array('', 'message_page', 'error', 'search_form', 'search_form_post', 'search_form_profile_post', 'search_results', 'register_form', 'login', 'error_with_login', 'contact'))">
<xen:if is="{$post.position} == 0">
<div style="padding: 0; text-align: center">
<div id="google-ads-1"></div>

<script type="text/javascript">

    /* Calculate the width of available ad space */
    ad = document.getElementById('google-ads-1');
    if (ad.getBoundingClientRect().width) {
        adWidth = ad.getBoundingClientRect().width; // for modern browsers
    } else {
        adWidth = ad.offsetWidth; // for old IE
    }

    /* Replace ca-pub-XXX with your AdSense Publisher ID */
    google_ad_client = "ca-pub-XXX";

    /* Replace 1234567890 with the AdSense Ad Slot ID */
    google_ad_slot = "123456789";

    /* Do not change anything after this line */
    if ( adWidth >= 728 )
      google_ad_size = ["728", "90"];  /* Leaderboard 728x90 */
    else if ( adWidth >= 468 )
      google_ad_size = ["468", "60"];  /* Banner (468 x 60) */
    else if ( adWidth >= 320 )
      google_ad_size = ["320", "50"]; /* Mobile Banner (320 x 50) */

    document.write (
     '<ins class="adsbygoogle" style="display:inline-block;width:'
      + google_ad_size[0] + 'px;height:'
      + google_ad_size[1] + 'px" data-ad-client="'
      + google_ad_client + '" data-ad-slot="'
      + google_ad_slot + '"></ins>'
    );

    (adsbygoogle = window.adsbygoogle || []).push({});

</script>

<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
</script>
</div>
</xen:if>
</xen:if>

Anyone?
 
Last edited:
I want to show ads to guests and members, so I deleted this from the original code.
Code:
<xen:if is="!{$visitor.user_id}">
...
</xen:if>


I would like to hide the user avatar, user info and center the ad.
Can somebody please tell me how to do that?

upload_2014-1-18_14-8-46.webp
 
I don't understand, there is no user avatar nor info for the ad.

Wrap the contents in a div with text-align:center to centre it.
 
The Responsive Ad Beta that Google Adsense gives us looks kinda of basic and is SUPER huge when I'm on my mobile phone.

Is this resource an alternative to using that beta?
 
The Responsive Ad Beta that Google Adsense gives us looks kinda of basic and is SUPER huge when I'm on my mobile phone.

Is this resource an alternative to using that beta?
Use advance instead of smart sizing .
 
Other than the one in the sidebar, the content above and below ads look good so I'm going to re-read ya resource.
 
My sidebar has other content which is fixed at 276px width so I don't bother resizing the sidebar one.

Besides which, the sidebar drops below so I doubt it's even seen.
 
No problem, glad it was of some use.

There are some 720 banners I think - on pages without sidebars.
 
Where it says
<xen:elseif is="in_array({$contentTemplate}, array('forum_list'))"/>

How do I add more templates to that list^^^
 
Can anyone please help me with the code to display a skyscraper in the sidebar at forum list and a large or medium rectangle inside the 1st post?
 
Use the ad_sidebar_below_visitor_panel template for the skyscraper.

For the post use the ad_message_body template and if you want to show an ad in the first post on every page, this conditional statement: <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">
 
Top Bottom