Home » » Selective Display of Widgets on Blogger

Selective Display of Widgets on Blogger


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'>
Hi to all welcome to WidgetsCorner
</b:if>
Displaying on all pages other than the homepage 
<b:if cond='data:blog.url != data:blog.homepageUrl'>
Seen to all pages but not for Homepage
</b:if>
Displaying something on the Archive Pages..
<b:if cond='data:blog.pageType == &quot;archive&quot;'>
Hello this is only on Archive page
</b:if>
Displaying something on non Archive Pages..
<b:if cond='data:blog.pageType != &quot;archive&quot;'>
For non archive only
</b:if>
Displaying something on post page only
<b:if cond='data:blog.pageType == &quot;item&quot;'>
Post page seen only
</b:if>
Displaying something on non post page only
<b:if cond='data:blog.pageType != &quot;item&quot;'>
This is a non post page
</b:if>
Displaying something on static  pages only
<b:if cond='data:blog.pageType == &quot;static_page&quot;'>
Hi 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;'>
Hi 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_Selected_Page_Url&quot;'>
This will be displayed on The_Selected_Page_Url only
</b:if>
(you will have to replace The_Selected_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_Selected_Page_Url&quot;'>
This will not be displayed on The_Selected_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
I don't see a way to use OR conditions,
There isn't any direct easy way to include AND in conditional statements
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'>
This is the first post on this page
</b:if>
This condition will work within the blogger post loop...
Share this games :

2 comments:

Team BlogJeez said...

love you honey... brilliant stuff for advanced usage of Blogger!

Unknown said...

nyc work

Post a Comment

Sign up for FREE daily Updates.