All Blogger Conditional Tags - Page type Conditional tags

Published

Are you a blogger? or a blogger template designer?
Then you should be knowing what are conditional tags in blogger, 
Actualy what are conditional tags?
have you heard of if, if else, conditions?

If you want to work something in only specified conditions, these tags will be helpful.
Blogger Conditional tags allows you to display files or pages or scripts only under conditions.
It is very similar to conditional tags in any other language. This includes tags such as if, if else. you can use it in your widgets, or blogger main template as well.
If Else type conditional programing in blogger can be done by using <b:if cond=' '>...</b:if> tag.
In this post am going to describe the use of conditional tags on html or widgets. 

1Home Page Only


2Everywhere Except Homepage


3Archive Page Only


4Everywhere except archive page


5Item Page or Post Page Only


6Everywhere except item page


7Static Page Only


8Everywhere except static page


9Specific URL Page Only


10Certain Labels Only









1 Home Page Only

To display a text message only on home page we use
<b:if cond='data:blog.url == data:blog.homepageUrl'> 
<p> This text will be displayed only on home page</p>
</b:if>

2 Everywhere except homepage we use

<b:if cond='data:blog.url != data:blog.homepageUrl'> 
<p>This text will be displayed everywhere except on home page</p>
</b:if>

If you want to display a widget only on home page, you will use the conditional code as highlighted on the following code for a blogger html/Javascript widget


<b:widget id='HTML1' locked='false' title='Testing Widget' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == data:blog.homepageUrl'> 
<!-- only display title if it's non-empty -->
<b:if cond='data:title != &quot;&quot;'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
</b:if>
<b:include name='quickedit'/>
</b:includable>
</b:widget>

3 Archive Page Only

To display html code only on archive page
<b:if cond='data:blog.pageType == &quot;archive&quot;'> 
<p>Text for Archive pages only</p>
</b:if>


4 Everywhere except archive page

To display html code everywhere except archive page
<b:if cond='data:blog.pageType != &quot;archive&quot;'>
<p>Text for everywhere except Archive pages</p>
</b:if>

5 Item/Post Page Only

To display html code only on item page
<b:if cond='data:blog.pageType == &quot;item&quot;'> 
<p>Text for post pages only</p>
</b:if>

6 Everywhere except item page

<b:if cond='data:blog.pageType != &quot;item&quot;'> 
<p>Text for everywhere except item pages</p>
</b:if>

7 Static Page Only

To display html code only on static pages

<b:if cond='data:blog.pageType == &quot;static_page&quot;'> 
<p>Text for static pages only</p>
</b:if>

8 Everywhere except static page

To display html code everywhere except static page
<b:if cond='data:blog.pageType != &quot;static_page&quot;'> 
<p>Text for everywhere except static pages</p>
</b:if>


9 Specific URL Only

To display only on specific URL
<b:if cond='data:blog.url == &quot;http://aslamise.blogspot.in/2012/12/all-blogger-conditional-tags.html&quot;'> 
<p>Text will display on above URL only</p>
</b:if>

10 Certain Labels Only

To display content on certain labels only:

<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.name == &quot;Testing Category&quot;'>
Text will be displayed only on Posts which have label Testing Category. </b:if>
</b:loop>

Note*: You will need to be inside Blog Posts loop in order to use Certain Labels Only code