Headlines News :
Home » , » Display Selective Blogger Widgets on homepage, archive,post page, or particular pages

Display Selective Blogger Widgets on homepage, archive,post page, or particular pages

Written By BlogKing on Wednesday, January 11, 2012 | 12:53 AM


Before getting into the details of selective display,let us discuss about the different types of pages on blogger.
1) home page- yea its your blogs home page as the name suggests(actually this is not a type. but i will still include it here..)
2) Archive Page- Refers to archive pages..
3) Item Page - Refers to Post Pages
4) Index Page - Includes home page + label page + search results page
5) Static Page – The newly introduced Blogger Pages
Selective Display..

There are different conditions to check the page type. You can use these conditions for the selective display.

You might like to display a welcome message on the home page only..

<b:if cond='data:blog.url == data:blog.homepageUrl'>
Welcome to my Blog
</b:if>


Displaying on all pages other than the homepage

<b:if cond='data:blog.url != data:blog.homepageUrl'>
this is not the homepage
</b:if>


Displaying something on the Archive Pages..

<b:if cond='data:blog.pageType == &quot;archive&quot;'>
Hii this is an archive page
</b:if>


Displaying something on non Archive Pages..

<b:if cond='data:blog.pageType != &quot;archive&quot;'>
Hii this is an non archive page
</b:if>


Displaying something on post page only

<b:if cond='data:blog.pageType == &quot;item&quot;'>
Hii this is a post page
</b:if>


Displaying something on non post page only

<b:if cond='data:blog.pageType != &quot;item&quot;'>
Hii this is a non post page
</b:if>

Displaying something on static  pages only

<b:if cond='data:blog.pageType == &quot;static_page&quot;'>
Hii this is a static page
</b:if>


Displaying something on  all other than static pages

<b:if cond='data:blog.pageType != &quot;static_page&quot;'>
Hii this is not a static page
</b:if>


You can use the conditional thing for the index type pages. But i don't find much use in that.

Now displaying something on a particular url only (may be a particular post page only or something like that)

<b:if cond='data:blog.url == &quot;The_Particular_Page_Url&quot;'>
this will be displayed on The_Particular_Page_Url only
</b:if>
(you will have to replace The_Particular_Page_Url with the url where you need the widget to be displayed..)

Now displaying something on all pages other than a particular url

<b:if cond='data:blog.url != &quot;The_Particular_Page_Url&quot;'>
this will not be displayed on The_Particular_Page_Url
</b:if>


Now how to use two conditions (or more).. the logical AND thing.. :)

<b:if cond='data:blog.url != &quot;The_Particular_Page_Url1&quot;'>
<b:if cond='data:blog.url != &quot;The_Particular_Page_Url2&quot;'>
this is not Particular_Page_Url1 and this is not Particular_Page_Url2
</b:if>
</b:if>


the else thing..
What if you need to display something on the homepage and something else on all other pages.. here comes the use of if else

<b:if cond='data:blog.url == data:blog.homepageUrl'>
This is the homepage
line1
line2
<b:else/>
This is not the homepage
line 3
line4
</b:if>


Different combinations are possible..

Limitations
1) I don't see a way to use OR conditions
2) There isn't any direct easy way to include AND in conditional statements
3) The main drawback is that we cant enclose an entire widget within the b:if tag.. you will get some message telling that a b:section cant have b:if s ie you can wrap an unexpanded widget within a b:if condition


Wrapping a widget with the conditional tags
Every widget other than the BlogPost Widget has this general structure

<b:widget id='something' locked='' title='' type=''>
<b:includable id='main'>
somethings here
</b:includable>
</b:widget>


Wrapping conditional tags can be done as

<b:widget id='something' locked='' title='' type=''>
<b:includable id='main'>
<b:if cond='data:blog.url == &quot;The_Particular_Page_Url&quot;'>
some things here
</b:if>
</b:includable>
</b:widget>


this code will display the widget on The_Particular_Page_Url only (you have to provide this url)

Another Limitation..
wrapping the blogpost widget is little complicated as it has many b:includables.. yea you can do that too.. :)

Another Important B:if condition..

Some of you might want to display adsense ads below the first post only..OK there is a condition for checking if the post is the first post or not..
<
b:if cond='data:post.isFirstPost'>
OH yea this is the first post on this page
</b:if>
This condition will work within the blogger post loop. 
Share this article :

No comments:

Post a Comment

 
Support : Creating Website | Adult Dating | | Johny Portal | Magazine Templates | Mp3 Sonhs Download |
Copyright © 2011. Blogger Free Tricks - All Rights Reserved
Template Modify by Myblogtriks Inspired Wordpress Hack
Proudly powered by My Blog Tricks