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
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
Hai Ashwini: I knew this trick with the Old Blog as you see on my blogspot blog http://everydayspace.blogspot.com
ReplyDeleteBut didn't know how to do this with the New Blogger..
well I am now focussing on my wordpress blog.... Every Day Space
Thanks for this good Post.
This is a great feature. I just implemented on my main site at Weird Weird Denial.
ReplyDeleteDue to the sections, I was at first confused, luckily it's solved
In your example, you used "!=", which corresponds to "NOT Equal". Therefore that code will post whatever content is between the tags on any pages that aren't Item pages, rather than item pages themselves, as you indicated.
ReplyDeleteI use the following code on my blog, because I find it useful to have different content on item pages from every other page:
[b:if cond='data:blog.pageType != "item"']
Index and Archive Page Stuff
[b:else/]
Item only page stuff
[/b:if]
Obviously, those brackets should be changed to less than/greater than signs.
Hope this helps.
Eric.Herboso.com
EricHerboso.blogspot.com
What about logical operation such as "and" and "or" in the tags? I can't find any tutorial about this, please help.
ReplyDeleteTiffany jewellery creates modern designer jewelries that are sought after by those who have the capacity to pay for its expensive pieces and more so by those who can't. I recollect an acquaintance asking for a loan because he wanted to give his girlfriend a silver charms engagement ring. I find it really amusing that he is actually buying the ring from money that he loaned, I guess it is not a very good start for a lasting relationship. I suggested to him to search online for some Tiffany charms , they're just as stunning but won't have you landed in jail for unpaid debts. Fortunately he listened to my suggestion and is now happily married and debt free.
ReplyDeleteThis is good to avoid distracting ads in the homepage that are really useless, and sometimes cover uo information from the post.
ReplyDeletethanks for codes.
ReplyDelete