.
,Sejarah jam gadang, danau singkarak, danau maninjau, hotel, tujuan wisata sumatera barat,daftar,jam gadang, fort de kock,West Sumatra, Sumatera Barat, Tourism

How to use conditional tags

Posted By admin Sunday, March 27, 2011

Before studying the conditional tag let's first agree that all the parts in a blog page consists of a collection of gadgets / widgets including the article page, sidebar, header, footer and so forth. Conditional tag or tags are conditional tags that are used to configure a gadget / widget or a particular element to be displayed or not displayed in specific pages. For example, on the main page we want to display the sidebar but when the visitor reaches the page after page of the article then the sidebar is not shown. Well, to set the sidebar is showing and not showing it is used Conditional Tags.
Conditional Tag Syntax
In general, the conditional tag written like this:

<b:if cond='[CONDITION]'>
...
</ B: if>

Conditional tag always begins with the tag <b:if> and closed with a closing </ b: if>. Then tag <b: if followed by the cond attribute. Cond attribute is defined as a condition or conditions that are used as the subject of a condition, and [CONDITION] is an attribute describing the object or purpose of the state / condition.

Collection Conditional Tags
Below is a collection of conditional tags are commonly used to customize specific pages.
1. Pages Index

<b:if cond='data:blog.pageType == "index"'>
...
</ B: if>

Contidional tag is used to check / compare conditions blog pages with index pages. Index page (index page) includes the front page (homepage), the page labels / categories and archive pages. If we read the conditional tag above went something like "if condition 'blog pages with index' then the code between the conditional tags will be displayed".

2. Page article (item)

<b:if cond='data:blog.pageType == "item"'>
...
</ B: if>

Contidional tag is used to check / compare conditions blog page with a page item. Page items (item page) is a page of an article per article and not the entire collection of articles. If we read the conditional tag above went something like "if condition 'blog page together with pages of articles (items)' then the code between the conditional tags will be displayed". Usually the article page (items) using the URL contained hurup month, year and title of the article include, for example; http://namablog.blogspot.com/2010/09/judul_artikel.html.

3. Static pages (static)

<b:if cond='data:blog.pageType == "static_page"'>
...
</ B: if>

Contidional tag is used to check / compare conditions blog pages with static pages. Static pages (static page) is another page articles or stand-alone page and its contents do not take from the article database. If we read the conditional tag above went something like "if condition 'blog pages with static pages' then the code between the conditional tags will be displayed". Usually static pages using the URL contained letters "p" such as, for example; http://namablog.blogspot.com/p/halaman_statis.html.

4. Pages Archive (archive)

<b:if cond='data:blog.pageType == "archive"'>
...
</ B: if>

Contidional tag is used to check / compare conditions blog page by page archive. Pages archive (archive page) is a page that displays a collection of articles taken the blog database. If we read the conditional tag above went something like "if condition 'blog page with the page file' then the code between the conditional tags will be displayed". Usually the archive page using the URL contained the month and year including, for example; http://namablog.blogspot.com/2010_01_01_archive.html.

5. Front Page (Homepage)

<b:if cond='data:blog.url == data:blog.homepageUrl'>
...
</ B: if>

or:

<b:if cond='data:blog.homepageUrl == data:blog.url'>
...
</ B: if>

Contidional tag is used to check / compare conditions blog pages with front page URL. If we read the conditional tag above went something like "if condition 'blog page with the URL of the front page' then the code between the conditional tags will be displayed". Usually the front page is the main page of our blog and the URL used is the main URL of our blog, for example; http://namablog.blogspot.com/.

6. Page URL Specific

<b:if cond='data:blog.url == "[URL]"'>
...
</ B: if>

for example, we will display banner ads on-the sidebar blogroll pages only (our library of friends). And his use of conditional tags as below:

<b:if cond='data:blog.url == "http://namablog.blogspot.com/2010/09/blogroll.html"'>
[Here gadget code or element to be displayed]
</ B: if>


Use of Conditional Tags
Below is a simple explanation for using a conditional tag in the template bloggers and gadget code or element placement, please further implement its own. simply to place the code gadget or elements in the conditional tags like the example below:

1). Conditional Use Tag One gadget or Element

<b:if cond='data:blog.pageType == "item"'>
Gadget or Element [will be displayed if the value is true (true)]
</ B: if>

Gadget or the element which lies between the conditional tags will be displayed if the results of the checking / comparison in cond attribute (ie 'data: blog.pageType == "item"') is true (true). Or more specifically, if we are blog pages look / appear in the browser address is a URL of an item (eg; http://namablog.blogspot.com/2010/09/artikelku.html) then gadget or element that exists between the conditional tags otherwise it will be shown Gadget or element will not be displayed.

2). Conditional Use Gadget or Element Tag Two

<b:if cond='data:blog.pageType == "item"'>
Gadget or Element [will be displayed if the value is true (true)]
<b:else/>
Gadget or Element [will be displayed if the value is false (false)]
</ B: if>

3). Tag Conditional Use More Than One Condition and More Than One gadget or Element

<b:if cond='data:blog.url == data:blog.homepageUrl'>
<b:if cond='data:blog.pageType == "item"'>
Gadget or Element [will be displayed if the value is true (true)]
<b:else/>
Gadget or Element [will be displayed if the value is false (false)]
</ B: if>
</ B: if>

Conditional Operators Tag
Operator conditional tag is a special tool to compare two values. Operator conditional tag consists of 2 types:
1. The operator "equals"

==

or in its scripting language to read "is equal to"

Example Case 1
Someone gave the puzzle to guess the contents of the egg in a box, if I answer right then I was given money USD. 10.000, - if I said I was not given any money. While inside the box there were 10 eggs, 10 eggs and then I replied. Then conditional tags were written as follows:

<b:if cond='10 == 10 eggs '>
I was given money USD. 10.000, -
</ B: if>

The answer: so I was given money USD. 10.000, -

Sample Case 2
Someone gave the puzzle to guess the contents of the egg in a box, if I answer right then I was given money USD. 10.000, - if I answer wrong then I have to pay USD 10.000, -. While inside the box there were 10 eggs, then I answer the 5 eggs. Then conditional tags were written as follows:

<b:if cond='10 == 10 eggs '>
I was given money USD. 10.000, -
<b:else/>
I pay USD 10.000, -
</ B: if>

The answer: so I paid USD 10.000, -

2. The operator "not equal"

! =
This is the inverse of the operator "equals "


Related Post



Follow by Email