Tips For Blogger Conditional Tags

Views

conditional tags bloggerI 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….

Home Page Only
  • 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 != &quot;&quot;'>
<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>

Archive Page Only
  • To display html code only on archive page

<b:if cond='data:blog.pageType == &quot;archive&quot;'>
<p>Text for Archive pages only</p>
</b:if>

  • To display html code everywhere except archive page

<b:if cond='data:blog.pageType != &quot;archive&quot;'>
<p>Text for everywhere except Archive pages</p>
</b:if>

Item / Post Page Only
  • To display html code only on item page

<b:if cond='data:blog.pageType == &quot;item&quot;'>
<p>Text for post pages only</p>
</b:if>

  • To display html code everywhere except item page

<b:if cond='data:blog.pageType != &quot;item&quot;'>
<p>Text for everywhere except item pages</p>
</b:if>

Static Page Only
  • To display html code only on static pages

<b:if cond='data:blog.pageType == &quot;static_page&quot;'>
<p>Text for static pages only</p>
</b:if>

  • To display html code everywhere except static page

<b:if cond='data:blog.pageType != &quot;static_page&quot;'>
<p>Text for everywhere except static pages</p>
</b:if>

Specific URL Only
  • To display only on specific URL

<b:if cond='data:blog.url != &quot;http://www.tech-hacks.com/2011/06/all-about-blogger-conditional-tags.html&quot;'>
<p>Text will display on above URL only</p>
</b:if>

Certain Labels Only
  • To display content on certain labels only

<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.name == &quot;Testing Category&quot;'>
Text will be displayed only on Posts which have label Testing Category.
</b:if>
</b:loop>

NOTE: You will need to be inside Blog Posts loop in order to use Certain Labels Only code
ARE YOU CONFUSED REGARDING THIS TUTORIAL?

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.

Need help with your blog?

Name

Email *

Message *

Popular Post

Comments