You might have noticed a strange thing in my new template. If you visit the home page of this blog, then there aren't Adsense Ads between post title and post body but when you visit Itempage { Page with one Post }, you get an Adsense Ad rectangle between the post title and post body.
I have mentioned an introduction in Display your backlinks with New Blogger templates but now I’ll be giving you a in depth analysis of Conditional Tags in New Blogger{Blogger beta} templates
Understanding Conditional Tags
The old blogger also used to support the conditional tag ,i.e, itempage. Anything wrapped inside these tags will be displayed only on the itempage.
& now we use the New Blogger which also supports conditional tags, a bit different though
<b:if cond='data:blog.pageType != "item"'>
</b:if>
A bit complicated? We’ll make it easy.
Lets have a sample if else condition
If john studies, he passes else he fails
Now lets have a second look on the code
<b:if cond='data:blog.pageType != "item"'>
Stuff
</b:if>
We are using the if condition to command that the lines wrapped inside it would only be displayed on itempages.
We haven’t used any else tag as it would be understood as there only two kinds of pages.{item & Main}
We have also used the end tag as all tags in XML are container tags.
Now just play around with the widgets using the “if” condition. A sample widget coding for an HTML/ JavaScript Element looks like this
<b:widget id='HTML5' locked='false' title='' type='HTML'>
Stuff
</b:widget>
Now just wrap it such that it displays only on Itempages
<b:if cond='data:blog.pageType != "item"'>
<b:widget id='HTML5' locked='false' title='' type='HTML'>
</b:widget>
</b:if>
Now the contents of this code would only be displayed in itempages. You can also switch from Item{page} to Main{page}
Based on this functionality, I have just wrapped my Adsense inside it. It looks something like this:-
<b:if cond='data:blog.pageType == "item"'>
<script type="text/javascript"><!--
google_ad_client = "pub-XXXXXXXXXXX";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
google_ad_channel = "";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "333333";
google_color_text = "000000";
google_color_url = "6C82B5";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</b:if>
You can have further reference from how to place ads between posts inside blogger xml templates to make your ad position more relevant in order to place it between post header line without any Xml errors
Using Conditional Tags with New Blogger Templates
Ashwini Khare
-
Saturday, June 9, 2007 -
blogger

Newer Post
Home

