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

Adsense Layout and Placement

Discussion in 'XenForo Questions and Support' started by swatme, Mar 21, 2011.

  1. swatme

    swatme Well-Known Member

    Hi

    is there any guide on adsense placement on XF?

    i tried to test the Ad_Message_below template
    but it shows the test text message in every messages...

    how can i set it to what post it will appear?
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    This will do it after the first post on every page.
    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">

    This will do it after the first post on the first page.
    <xen:if is="{$post.position} == 0">

    Click the link in my signature for more conditionals.
     
    DerTobi75, Alien and swatme like this.
  3. swatme

    swatme Well-Known Member

    geez i never new that easy :) thanks brogan.

    the hardest part is putting a 468x60 banner on the ad_header
    but it wont work the way i want.

    I want it to be in middle and center (between the xenforo header logo and the signup/link)
    i tried to use
    <center>img src graphics code here</center>
    and
    also putting inside the table,
    still wont proceed as desired.

    any idea?
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Use this code to center it:

    Code:
    <div style="text-align: center;">
    	BANNER CODE HERE
    </div>
    
     
  5. trilogy33

    trilogy33 Well-Known Member

  6. Brogan

    Brogan XenForo Moderator Staff Member

    He has it outside the main container.

    I doubt he is using the ad template, probably just edited the main template manually.
     
  7. trilogy33

    trilogy33 Well-Known Member

    Yes I thought so. I had wondered if it were an addon tbh.
    Nevermind, I'll go with the hook flow until I decide it's really ugly. Seems ok so far.
    Ta :)

    Ninja Edit: Had to expand the Flexile style somewhat, the 728 width banner broke out! Yah! :eek:
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    You can always create your own ad template and then include it in the template.

    That's what I've done to get ads below the bottom breadcrumb.
     
  9. trilogy33

    trilogy33 Well-Known Member

    So an ad template within an ad template? Curious ;)
     
  10. Brogan

    Brogan XenForo Moderator Staff Member

    No, I created my own template and included that in the PAGE_CONTAINER template.

    Code:
    <xen:hook name="page_container_breadcrumb_bottom">
    <div class="breadBoxBottom"><xen:include template="breadcrumb" /></div>
    <xen:include template="cta_adsense_banner_wide" />
    </xen:hook>
     
    trilogy33 likes this.
  11. trilogy33

    trilogy33 Well-Known Member

    Done and thanks. :)
    Default template seems to be ok centered with no margin adjustment.

    Code:
    <div style="text-align: center;">
    
    Flexile needs something extra as per Jaxel's page:

    Code:
    <div style="text-align: center; margin: -15px auto 12px;">
    
     
  12. Quillz

    Quillz Well-Known Member

    Where in the temple would I put this code? At the very bottom?

    Also, I've generated an AdSense code but can't figure out where to actually put it to get it to show up.
     
  13. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Admin CP -> Appearance -> Templates -> PAGE_CONTAINER

    Brogan put his code in context so you know where to put it. He added this code:

    Code:
    			<xen:include template="cta_adsense_banner_wide" />
    
    Like so:

    Code:
    			<xen:hook name="page_container_breadcrumb_bottom">			
    			<div class="breadBoxBottom"><xen:include template="breadcrumb" /></div>
    			<xen:include template="cta_adsense_banner_wide" />
    			</xen:hook>
    
    This code is down towards the bottom of the PAGE_CONTAINER template.

    In Brogan's example he created a new template called cta_adsense_banner_wide and placed his Adsense code in there:

    Admin CP -> Appearance -> Templates -> Create New Template
     
  14. Quillz

    Quillz Well-Known Member

    Okay, I've done those exact steps and I still have nothing showing up on my board.
     
  15. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Check the source code of the page. Does your Adsense code show in the source? It's possible the code is there but it isn't generating anything.
     
  16. Quillz

    Quillz Well-Known Member

    Here's the code I'm using...

    Code:
    <script type="text/javascript"><!--
    google_ad_client = "ca-pub-2578191216111888";
    /* XenForo */
    google_ad_slot = "8174956989";
    google_ad_width = 728;
    google_ad_height = 90;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    That's what I have in cta_adsense_banner_wide. Should I have something else in that template, as well?
     
  17. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Did you add that include to the PAGE_CONTAINER template as well?

    Code:
    			<xen:hook name="page_container_breadcrumb_bottom">			
    			<div class="breadBoxBottom"><xen:include template="breadcrumb" /></div>
    			<xen:include template="cta_adsense_banner_wide" />
    			</xen:hook>
    
     
  18. Quillz

    Quillz Well-Known Member

    Yes, I have that exact piece of code in my PAGE_CONTAINER template, and there is simply nothing at all on my board.

    Code:
                <xen:hook name="page_container_breadcrumb_bottom">
                <div class="breadBoxBottom"><xen:include template="breadcrumb" /></div>
                            <xen:include template="cta_adsense_banner_wide" />
                </xen:hook>
    Code:
    <script type="text/javascript"><!--
    google_ad_client = "ca-pub-2578191216111888";
    /* XenForo */
    google_ad_slot = "8174956989";
    google_ad_width = 728;
    google_ad_height = 90;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    EDIT: Wait, it appears to be working. It is sometimes showing up on page refreshes, and sometimes not. Could it be a cache issue on my end?
     
  19. Quillz

    Quillz Well-Known Member

    Also, is there a way to have the template work globally, or do I have to manually apply the template edits to each style?
     
  20. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    In that case you know the code is working, but Adsense isn't always returning an ad. That can be normal under certain circumstances. See this article:

    http://www.yugatech.com/blog/adsense/seeing-blank-adsense-ads/

    Template modifications that are common to multiple styles can be added to a parent style. All styles underneath a parent will inherit the parent's customizations. Or you can just make the same changes to all of your styles individually.
     

Share This Page