1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to add Google adsense?

Discussion in 'XenForo Questions and Support' started by bogus, Apr 27, 2011.

  1. bogus

    bogus Guest

    Hello. I´ve just read about the new ad Templates and now i want to add an adsense Code into ad_above_top_breadcrumb
    How do i have to add the Code?
     
  2. ragtek

    ragtek Guest

    you still need to edit the template;)
     
  3. bogus

    bogus Guest

    Das hilft nicht wirklich ;) Das ich es bearbeiten muss ist mir auch klar

    I need to know HOW to add the Code not that i still have to edit the Template...
    Do i have to add a new Template and add into ad_above_top_breadcrumb
    something like <xen:include template="TEMPLATE NAME" />
    Or do i have to add the Code directly into the breadcrump Template and if how?
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Paste the Google Adsense code directly into the ad_ template.

    For example:
    Code:
    <xen:if is="{$quickNavSelected} != 'node-55'">
        <xen:if is="!{xen:helper ismemberof, $visitor, 3} AND !{xen:helper ismemberof, $visitor, 4} AND !{xen:helper ismemberof, $visitor, 5} AND !{xen:helper ismemberof, $visitor, 6} AND !{xen:helper ismemberof, $visitor, 7}">
            <div style="text-align: center">
                <script type="text/javascript"><!--
                google_ad_client = "your-adsense-id";
                /* Banner Narrow (Above Upper Breadcrumb) */
                google_ad_slot = "4545463";
                google_ad_width = 468;
                google_ad_height = 60;
                //-->
                </script>
                <script type="text/javascript"
                src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                </script>
            </div>
        </xen:if>
    </xen:if>
    In the example above I have a few conditionals to stop adverts being displayed on a Page node (55) and to 5 user groups.
     
    aiman.h.kallaf likes this.
  5. bogus

    bogus Guest

    Thanks Brogan.
    If i want to display it for eveyone without any conditionals i also could just use
    Code:
            <div style="text-align: center">
                <script type="text/javascript"><!--
                google_ad_client = "your-adsense-id";
                /* Banner Narrow (Above Upper Breadcrumb) */
                google_ad_slot = "4545463";
                google_ad_width = 468;
                google_ad_height = 60;
                //-->
                </script>
                <script type="text/javascript"
                src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                </script>
            </div>
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

    Yes, you can even remove the div centering it if you wish.

    Just copy the adsense code directly from your account.
     
    aiman.h.kallaf likes this.
  7. bogus

    bogus Guest

    Thanks that helped ;)
     
  8. How do i go about making it so it doesnt show in the threads, but only in the nodes?
     
  9. Brogan

    Brogan XenForo Moderator Staff Member

    I'm not sure what you mean by the nodes, but just search the templates for everything beginning ad_ and use the appropriate one.
     
  10. Like only make it display in the thread lists, and not in the actually thread discussion.
     
  11. Brogan

    Brogan XenForo Moderator Staff Member

    Try ad_thread_list_below_stickies
     
  12. kingston

    kingston Well-Known Member

    Brogan,

    I can't seem to get my ads to line up on the left. Any Ideas?

    Here is an example page: http://forum.fierceboard.com/threads/small-junior-4.17936/

    Here is my code to insider the ad:

    HTML:
    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND !{xen:helper ismemberof, $visitor, 20} AND !{$message.conversation_id}">
    <li class="message">
    
            <div class="messageUserInfo"></div>
    
            <div class="messageInfo primaryContent">
                <div class="messageContent" >
                    <blockquote class="messageText ugc baseHtml" >
    <div style="text-align: left">
    <script type="text/javascript"><!--
    google_ad_client = "***********";
    google_ad_slot = "*********";
    google_ad_width = 728;
    google_ad_height = 90;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    </div>
                  </blockquote>
                </div>
            </div>
        </li>
    </xen:if>
     
  13. Brogan

    Brogan XenForo Moderator Staff Member

    You're using the messageInfo class which has a 140px left margin.

    Why are you using all of those classes?

    Just place the ad code in the template.
     
  14. kingston

    kingston Well-Known Member

    No idea. I think I copied it from someone earlier on here. Silly legacy code and me not knowing what I am doing. Thanks for the help. Fixed it.
     

Share This Page