I discovered this great website “TECH HACKS” that teach how this “Blogger Conditional Tags” can be easily used by young webmaster and blogger enthusiast. This will allow you to have a full control to your widgets and directly to your template. Lets read What Amritpal Singh explained about conditional tags .
“Conditional tags allow you to specify parts of your template to appear only under certain conditions. It is very similar to conditional tags in any other language. This includes tags such as if, if else. These conditional statements could be used on widgets, or actual html codes you may want to display on certain pages. If Else type conditional programing in blogger can be done by using <b:if cond=' '>...</b:if> tag. In this post we have examples of the use of conditional tags on html or widgets.” Alright, lets see how this conditional tags works and how to used them the right way. Just keep Reading….
- To display a text message only on homepage
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<p> This text will be displayed only on home page</p>
</b:if>
- And to display it everywhere except homepage
<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 != ""'>
<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>
- To display html code only on archive page
<b:if cond='data:blog.pageType == "archive"'>
<p>Text for Archive pages only</p>
</b:if>
- To display html code everywhere except archive page
<b:if cond='data:blog.pageType != "archive"'>
<p>Text for everywhere except Archive pages</p>
</b:if>
- To display html code only on item page
<b:if cond='data:blog.pageType == "item"'>
<p>Text for post pages only</p>
</b:if>
- To display html code everywhere except item page
<b:if cond='data:blog.pageType != "item"'>
<p>Text for everywhere except item pages</p>
</b:if>
- To display html code only on static pages
<b:if cond='data:blog.pageType == "static_page"'>
<p>Text for static pages only</p>
</b:if>
- To display html code everywhere except static page
<b:if cond='data:blog.pageType != "static_page"'>
<p>Text for everywhere except static pages</p>
</b:if>
- To display only on specific URL
<b:if cond='data:blog.url != "http://www.tech-hacks.com/2011/06/all-about-blogger-conditional-tags.html"'>
<p>Text will display on above URL only</p>
</b:if>
- To display content on certain labels only
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.name == "Testing Category"'>
Text will be displayed only on Posts which have label Testing Category.
</b:if>
</b:loop>
If you have any difficulties implementing and/or following this tutorial, Feel free to keep in touch with me and ill try my best to work it out.
No comments:
Post a Comment
● Be sure to click "Notify Me" below, to get notified for follow up response.
● Respect! Do not Spam/Flood, you will be banned if you do so.
● Admin will try to get back to you as soon as we possibly can.