Adsense Layout and Placement

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?
 
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.
 
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?
 
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?

Use this code to center it:

Code:
<div style="text-align: center;">
	BANNER CODE HERE
</div>
 
He has it outside the main container.

I doubt he is using the ad template, probably just edited the main template manually.
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:
 
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.
 
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>
 
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>
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;">
 
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>
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.
 
Where in the temple would I put this code? At the very bottom?

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.

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

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
 
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.
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?
 
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>
 
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?
 
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?

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/

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

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.
 
Top Bottom