Understanding If Conditional Tags For Blogger

If conditional statements are very important part of any programming language. It is used to determine certain logic based on a given condition. Similarly, Blogger blogs too have HTML if conditions which are specific to only Blogger HTML templates/codes. The if conditions which we are going to learn today are highly specific to Blogger HTML standards and these codes work only with Blogger templates.

We have already seen how to use conditional tags to make the gadgets appear on post page, home page and so on.

If conditional tags are important because, you can easily control the Blogger template elements.

We will see the supported if conditional statements for Blogger now:

Two types of if statements:
1. Type 1
<if condition >
Some text
<if ends>

2. Type 2
<if condition>
Some statements
<else>
Some statements
<if ends>

Type of Conditional Tags for Blogger HTML template:
1. For Home Page
Eg: http://www.itechcolumn.com or http://yourblogname.blogspot.com

<b:if cond='data:blog.url == data:blog.homepageUrl'>
TEXT/IMAGE/GADGET/CODE
</b:if>

2. For Static Page(Stand-alone Pages)
Eg: http://www.itechcolumn.com/p/itechcolumn-table-of-contents.html

<b:if cond='data:blog.pageType == &quot;static_page&quot;'>
TEXT/IMAGE/GADGET/CODE
</b:if>
3. For Post Page(Link to the full post page)
Eg: http://www.itechcolumn.com/?p=141

<b:if cond='data:blog.pageType == &quot;item&quot;'>
TEXT/IMAGE/GADGET/CODE
</b:if>


<b:if cond='data:blog.pageType == &quot;archive&quot;'>
TEXT/IMAGE/GADGET/CODE
</b:if>
5. Index Page
This conditional tag is used every other pages expect the post pages.

<b:if cond='data:blog.pageType == &quot;index&quot;'>
TEXT/IMAGE/GADGET/CODE
</b:if>

6. For only a particular page using page URL as

<b:if cond='data:blog.pageType == &quot;URL_OF_THE_PAGE&quot;'>
TEXT/IMAGE/GADGET/CODE
</b:if>

TO USE ELSE CONDITION AS:
Eg:

<b:if cond='data:blog.pageType == &quot;URL_OF_THE_PAGE&quot;'>
TEXT/IMAGE/GADGET/CODE
</b:else>
SOME TEXT/IMAGE/GADGET/CODE </b:if> 

ALTER THE IF CONDITON USING != AS:
Eg:

<b:if cond='data:blog.pageType != &quot;URL_OF_THE_PAGE&quot;'>
TEXT/IMAGE/GADGET/CODE </b:if>

The above statement will change the condition to if not equals to. So it says, if not equal to the URL of the page execute the statements(TEXT/IMAGE/GADGET/CODE).

TIPS:
Replace the TEXT/IMAGE/GADGET/CODE with your image code, text, any gadget code or any other HTML codes to make it appear on a certain page you wish.

We will discuss more on this to make some customization in the future posts. Thanks for tuning up. Enjoy the post and have a great time reading.

~iTechColumn

Leave a Reply

Your email address will not be published.