UPDATE: This post changed to incorporate the recommendation left by David Rhodes in the comments.
There's some good information in the Community Server forums about displaying Google Adsense ads in Community Server. This Howto post provides the basic method for doing so. However, later in the thread, the issue of displaying Google ads more than once on the page came up and was left without a final solution. I was able to do it successfully. For evidence, see the ads on this blog post.
Disclaimer: In this situation, I am using the same Adsense layout in both positions. This post does not show how to display two different Adsense layouts on the same page.
Here's how I did it...
- Open skin file Themes\Default\Skins\Skin-Ads.ascx
- Locate the span with id GoogleAdsense.
- Between the <span> and </span> tags, paste a copy of your Google Adsense code. Following is an example from my Skin-Ads.ascx. So that the ads would match the layout of the page, I added a new style to Themes\Default\Styles\blog.css and surrounded the Google-generated script with a div referencing the style.
<span id="GoogleAdsense" runat="server" visible="false">
<div class="AdsenseArea">
<script type="text/javascript"><!--
google_ad_client = "pub-3080852261786875";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "E6E6E6";
google_color_bg = "E6E6E6";
google_color_link = "A9501B";
google_color_text = "000000";
google_color_url = "006699";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</span>
- Open file Themes\Blogs\Default\LayoutTemplate.ascx.
- Insert a CS:Ads control into the file, before and after the div containing the CS:BodyControl element. Following is an example of the CS:Ads control:
<CS:Ads ID="Ads1" Zone="GoogleAdsense" runat="server" />
Following is some of the markup from my own LayoutTemplate.ascx file:
<
Blog:BlogTitleHeader id="bth" runat="server" />
<Blog:CurrentSearch id = "cs" runat = "Server" />
<CS:Ads ID="Ads1" Zone="GoogleAdsense" runat="server" />
<br />
<div class="CommonContent">
<CS:BodyTemplate id="BodyTemplate" runat="Server" />
</div>
<br />
<CS:Ads ID="Ads2" Zone="GoogleAdsense" runat="server" />
I have seen the case where Adsense doesn't display any content in the bottom CS:Ads control. I assume that's because there was nothing pertinent to the content in that blog post. But as mentioned earlier, this scheme has successfully displayed ads in two locations on a page.
--
Sean Winstead
Tags: Adsense, CommunityServer