Blogger / Blogspot Conditional Tag For Different Page Type

Blogger / Blogspot Conditional Tag For Different Page Type
Blogger / Blogspot Conditional Tag For Different Page Type
Blogger / Blogspot Conditional Tag For Different Page Type



Lets start

Blog or Blogspot Design Depend Conditional tag. Every Blogger Use Different Conditional tag For Different Page Type.

Now I am Saying Kinds Of Conditional Tag.

Follow Me.

A conditional template tag in Blogger looks like following
[CODE]
<b:if cond='condition_expression'>
    <!-- content when condition is satisfied -->

</b:if>
[/CODE]

List of Conditional tags for page types Archive page
[CODE]
<b:if cond='data:blog.pageType == "archive"'>
<!--archive_Page-->
</b:if>
[/CODE]

Error Page (404)
[CODE]
<b:if cond='data:blog.pageType == "error_page"'>
<!-- all error pages-->
</b:if>
[/CODE]

Index Page
[CODE]
<b:if cond='data:blog.pageType == "index"'>
<!-- all index pages -->
</b:if>
[/CODE]

Homepage
[CODE]
<b:if cond='data:blog.url == data:blog.homepageUrl'> 
<!-- only homepage -->
</b:if>
[/CODE]

Item (post) pages
[CODE]
<b:if cond='data:blog.pageType == "item"'>
<!-- all item pages -->
</b:if>
[/CODE]

Specific Post by URL
[/CODE]
<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "2014/08/foo.html"'> 
<!-- a item page from august 2014 with post-title 'foo'-->
</b:if>
[/CODE]

Label page
[CODE]
<b:if cond='data:blog.searchLabel'>
<!-- all label pages -->
</b:if>
[/CODE]

Specific Label Page
[CODE]
<b:if cond='data:blog.searchLabel == "foo"'>
<!-- for label 'foo' -->
</b:if>
[/CODE]

Search page
[CODE]
<b:if cond='data:blog.searchQuery'>
<!-- all search pages -->
</b:if>
[/CODE]

Specific Search Query page
[CODE]
<b:if cond='data:blog.searchQuery == "foo"'>
<!-- for query 'foo' -->
</b:if>
[/CODE]

Static page
[CODE]
<b:if cond='data:blog.pageType == "static_page"'>
<!-- all static pages -->
</b:if>
[/CODE]

Specific Static page by URL
[CODE]
<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "p/foo.html"'> 
<!-- a specific static page with name 'foo' -->
</b:if>
[/CODE]

AND/OR/NOT

AND

[CODE]
<b:if cond='data:blog.pageType == "index"'>
  <b:if cond='data:blog.searchQuery'>
    <!--search_page AND index_page-->
  </b:if>
</b:if>
[/CODE]

OR

[CODE]
<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "p/foo.html"'> 
  <!-- static_site foo OR static_site bar -->
      <b:else/>
<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "p/bar.htm"'> 
  <!-- static_site foo OR static_site bar -->
   </b:if>
</b:if>
[/CODE]

NOT

[CODE]
<b:if cond='data:blog.pageType != "item"'>
  <!-- all pages except item pages -->
</b:if>

<b:if cond='data:blog.url != data:blog.homepageUrl'> 
  <!-- all pages but NOT homepage -->
</b:if>
[/CODE]

How to Use conditional tags:
To apply a conditional tag to some content, simply put the content
inside the opening 
<b:if cond…> and the closing </b:if> like:

[CODE]
<b:if cond='data:blog.pageType == "item"'>
    # THIS CONTENT WILL BE EXECUTED IF CONDITION IS TRUE
</b:if>
[/CODE]

In the example above, the content will only appear on post pages.

The content can be a div, a section, a style tag or another conditional tag etc.

If you want to specify a alternate content (when the condition is false), you need to insert a <b:else/> tag followed by the content, like this:

[CODE]
<b:if cond='data:blog.pageType == "item"'>
    # THIS CONTENT WILL BE EXECUTED IF CONDITION IS TRUE
    # i.e. if current page is post (item) page
<b:else/>
    # THIS CONTENT WILL BE EXECUTED IF CONDITION IS FALSE
    # i.e. if not post page
</b:if>
[/CODE]


The <b:else/> also works like an OR operator as explained above.


পোস্ট রেটিং করুন
ট্যাগঃ
About Author
4 comments
Sort by