Sunday, October 10, 2010

How to Display Multiple Ads in the Left Navigation?

You can find the solution for adding ads to the left navigation at http://solutionsforofficelive.com/googleadsense2.aspx.

The easiest way to add multiple ads to the left navigation is to add two sets of code for an ad and separating them with a <br /> tag.  If you want more ads simply add an <br /> tag between the ad codes.  Also if you want additional space between the ads simply add additional <br /> tags.  You should be able to insert ads from multiple sources if desired.  These codes use the Custom Footer Module or Custom Header and Navigation module as well.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:template match="/">
<div id="adLoader">
Replace this is the first ad code
<br />
Replace this is the second ad code
</div>
<script type="text/javascript">
var leftNav = document.getElementById('IWS_WH_Elem_LeftNav');
leftNav.appendChild(document.getElementById('adLoader'));
</script>
</xsl:template>
</xsl:stylesheet>

Example:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:template match="/">
<div id="adLoader">
<script type="text/javascript"><![CDATA[<!--
google_ad_client = "pub-47734912835080";
/* Left Nav 160x600 Text or Image */
google_ad_slot = "50235832";
google_ad_width = 160;
google_ad_height = 600;
//-->]]>
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br /><br />
<script type="text/javascript"><![CDATA[<!--
google_ad_client = "pub-47734912835080";
/* Left Nav 160x600 Text or Image */
google_ad_slot = "50235832";
google_ad_width = 160;
google_ad_height = 600;
//-->]]>
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<script type="text/javascript">
var leftNav = document.getElementById('IWS_WH_Elem_LeftNav');
leftNav.appendChild(document.getElementById('adLoader'));
</script>
</xsl:template>
</xsl:stylesheet>

No comments:

Post a Comment