|
Tweet |
According to google, Conditional tags are Blogger template tags that allow us to discover even greater flexibility and better control over the template design. We call them conditional because they allow us to specify which parts of the template will appear under certain conditions. If in any chance you want to place a certain widget in the certain place in your blog like Home page, Post pages or Static page etc, this might become handy.
The simplest Conditional tags there is as state below (note that these are the old one. It might not work on most recent templates) :~
<MainPage></MainPage>
<ArchivePage></ArchivePage>
<ItemPage></ItemPage>
<MainOrArchivePage></MainOrArchivePage>
If you have something in your template that you only want to appear on the main page of your blog, simply put <MainPage> and </MainPage> tags around it. This can be apply as well for the other page types. More info here.
List of Conditional tags (New conditional tags. Work on most recent templates)
1. Index pages (include homepage, labels and archive page)
<b:if cond='data:blog.pageType == "index"'>
..execute if satisfy the condition
</b:if>
2. Post (item) page
<b:if cond='data:blog.pageType == "item"'>
..execute if satisfy the condition
</b:if>
3. Static Page
<b:if cond='data:blog.pageType == "static_page"'>
..execute if satisfy the condition
</b:if>
4. Archive page
<b:if cond='data:blog.pageType == "archive"'>
..execute if satisfy the condition
</b:if>
5. Homepage
<b:if cond='data:blog.url == data:blog.homepageUrl'>
..execute if satisfy the condition
</b:if>
6. Specific page/url
<b:if cond='data:blog.url == "BLOG_PAGE_URL"'>
..execute if satisfy the condition
</b:if>
7. Specific Label Page
<b:if cond='data:blog.url == "http://BLOG_NAME.blogspot.com/search/label/LABEL_NAME"'>
..execute if satisfy the condition
</b:if>
8. First post (checking if the post is the first post)
<b:if cond='data:post.isFirstPost'>
..execute if satisfy the condition
</b:if>
To specify the condition as not true, change the comparison operator from == (is equal to) to != (is not equal to).
Logical AND Conditional tags
<b:if cond='data:blog.url == "BLOG_PAGE_URL"'>
<b:if cond='data:blog.url == "BLOG_PAGE_URL"'>
..execute if satisfy the condition
</b:if>
</b:if>
Logical ELSE Conditional tags
<b:if cond='data:blog.url == data:blog.homepageUrl'>
..This is homepage
<b:else/>
..This is not homepage
</b:if>
Applying the Conditional tags
Simply put the content/code/HTML between the opening tags
<!-- facebook share -->
<b:if cond='data:blog.pageType == "item"'>
<a expr:share_url='data:post.url' name='fb_share' rel='nofollow' type='box_count'/>
<script src='http://static.ak.fbcdn.net/connect.php/js/FB.Share' type='text/javascript'/>
</b:if>
<!-- /facebook share -->
Wrapping a widget with the conditional tags
Although some widget, e.g: Adsense/Facebook Like etc can be wrapped directly,
this particular widget with a common general structure required a little trick on it :
<b:widget id='something' locked='' title='' type=''>
<b:includable id='main'>
..The widget here
</b:includable>
</b:widget>
It can be done like this
<b:widget id='something' locked='' title='' type=''>
<b:includable id='main'>
<b:if cond='data:blog.pageType == "item"'>
..The widget here
</b:if>
</b:includable>
</b:widget>
Credit : This is as a refference only. I've compile this out from these blog..
Tweet |
You may also like this [...] |
|
|
|
nice compilation..
i still didn't get it please explain me..
Thanks for linking to BloggerSentral :)
You might want to mention that the conditional tags at the beginning of the post are for (the old, pre 2006) Classic templates while the rest are for (the new) Layout templates.
They can't be used interchangeably.
ahh yes they are the old one. on some template these tag might not work.. thanks. i'll change the info a bit..
@meesum raza : Hi, you can wrap the facebook like button with the conditional tags like this.. it'll do the trick. to put it simply, these conditional tag will only make the like button show up on single page rather than your homepage.
<!-- facebook share -->
<b:if cond='data:blog.pageType == "item"'>
<iframe allowTransparency='true' expr:src='"http://www.facebook.com/plugins/like.php?href=" + data:post.url + "&layout=standard&show_faces=true&width=100&action=like& font=arial&colorscheme=light"' frameborder='0' scrolling='no' style='border:none; overflow:hidden; width:450px; height:60px;'/>
</b:if>
<!-- /facebook share -->
how can i learn blogger xml complete. is any website you know please share with me
well its depend. if you just give me the specific of what you want then maybe i can help. I also learned from from all over the place.. no specific website, just google it.
your welcome..
Post a Comment