Using Conditional Tags with New Blogger Templates

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

Comments

  1. Hai Ashwini: I knew this trick with the Old Blog as you see on my blogspot blog http://everydayspace.blogspot.com

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

    ReplyDelete
  2. This is a great feature. I just implemented on my main site at Weird Weird Denial.

    Due to the sections, I was at first confused, luckily it's solved

    ReplyDelete
  3. 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.

    I 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

    ReplyDelete
  4. Welcome to come here to buy the SWG credits, in here you can buy the cheap SWG credits, only need a little money, do you want to buy the cheapest star wars galaxies credits, if you very want to buy SWG credits, you really need to come here, we will give you a big surprise.

    ReplyDelete
  5. What about logical operation such as "and" and "or" in the tags? I can't find any tutorial about this, please help.

    ReplyDelete
  6. Tiffany 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.

    ReplyDelete
  7. This is good to avoid distracting ads in the homepage that are really useless, and sometimes cover uo information from the post.

    ReplyDelete
  8. Here’s a list of tools you will need to start: Jewelers’ pandora jewellery wire cutters - If you can only afford one pair, get memory wire shears. pandora charms These are designed to make clean cuts on tough memory wire, so can also be used for pandora charms uk softer wires. Chain-nose pliers sometimes called cheap pandora charms needle-nose pliers – Very versatile for picking up and grasping small items, pandora charms sale bending eye pins, closing jumps rings, even closing crimp beads. discount pandora charms Round-nose pliers – Used for creating loops on beaded head and eye pins. Can also be used for winding your own jump rings and as the second pliers you’cheap pandora ll need for closing jump rings. Optional pliers – Wire-looping pliers which have several graduated circumferences to allow you to form perfectly uniform jump rings and loops in place of the pandora discount uk round-nose pliers mentioned above. Crimping pliers which have little notches to allow you to both flatten a crimp bead and then bend it to form a rounded finished look instead of the flat crimp you pandora uk get using the chain-nose pliers. As for materials, I recommend some assortment packs of beads in coordinating colors, some decorative metal spacers, seed beads in both silver and gold These can serve as spacers and beautifully set off pandora sale your other beads., tube-shaped crimp beads Buy the best you can find – these are what hold it all together!, head and eye pins. Other than that, let your choice of project be your guide. You might want some silver or pewter charms.

    ReplyDelete
  9. The symbol pandora bracelets of trustworthiness, faithfulness, and fidelity. pandora jewellery It was thought that the fourth pandora charms finger contained a special pandora canada vein that was connected directly pandora shop to the heart, and therefore cheap pandora this became the official finger for pandora necklaces the wedding band..Rings pandora sets have been used as a symbol of pandora earrings love for many years. To purchase a pandora sale large diamond, you would have a diamond that is pandora beads quite rare. This is shown in pandora 2010 theprice of a diamond ring that highlights pandora bangles a 2-caret gem versus a ring that has cheap pandora canada two 1-caret stones set in the cheap pandora beads center.

    ReplyDelete
  10. EVISU ジーンズ 価格Serial denim entrepreneur Scott Morrison is at it again.EVISU ジーンズ 直営店 He's the co-founder behind both Paper Denim and Cloth and Earnest Sewn, and was CEO and creative director for Evisu before they shuttered their US business and moved the entire operation to Hong Kong. Now,エヴィス ジーンズ 店舗 he's launching a new line of denim called 3x1エヴィス ジーンズ.

    ReplyDelete

Post a Comment

Please avoid hyper links in Comments. Any offensive comment will be deleted

Popular posts from this blog

New blogger templates (XML) 3 columns

Why I do not shift to a custom domain

Site Report for October, Perfomance report of AdSense referrals