The logical operators of Blogger are used to comparing a Boolean values, the result will returns as Boolean value. The concept of logical operators is simple. They allow a program to make a decision based on multiple conditions. Each operand is considered a condition that can be evaluated to a true or false value.

Blogger Logical Operator Syntax

Operator Meaning Default syntax
and AND boolean && boolean
&& boolean and boolean
or OR boolean || boolean
|| boolean or boolean
not Is not !boolean
! not boolean
Functional Syntax Operand operator ( Operand,Operand )
Operand operator ( Operand operator Operand )
Operand operator ( Operand operator ( Operand operator Operand ))

  • The result of the operation will always be a Boolean value.
  • The operands must be of type boolean and can be: An Blogger value, a data set or the result of an Blogger Expression.
  • A non-Boolean data is considered false when it is empty and true when it contains a content.

Blogger Logical Operator [and]

The "and" operator returns a true value when all operands are true. When one of the operands returns value is false, the result will be false.


Blogger Logical Operator [or]

The "or" operator returns a true when one of the operands is true. When all operands return value is false, the result will be false.


Blogger Logical Operator [not]

The operator "not" mean to reverse the value of the operand. true becomes false, and vice versa. Also, the operator "not" can be combined with membership operator .

not in

not contains


Blogger Logical Operation Example

The operator "AND"
<b:if cond='data:view.isMobile and data:view.isHomepage'>
  <!-- item --> 
</b:if>
If the Blog has parameter m=1, and the current view is Homepage, the item will be displayed.
The operator "OR"
<b:if cond='data:view.isLabelSearch or data:view.isHomepage'>
  <!-- item --> 
</b:if>
The item will be shown only on Label Page or Homepage.
The operator "NOT"
<b:if cond='!data:view.isMobile'>
  <!-- item --> 
</b:if>
Resut of the operation is always true if the blog does not have parameter m=1.
Nesting in a Comparison operation
<b:if cond='data:blog.pageType == "item" or data:blog.pageType == "index"'>
  <!-- item --> 
</b:if>
The result of the operation will be the number of posts containing labels and titles.
Nesting in a Lambda operation
<b:eval expr='data:posts count (p => p.labels.any and p.title)'/>
The result of the operation will be the number of posts containing labels and titles.
Functional Operation
<b:if cond='data:blog.pageType == "archive" or (data:blog.pageType == "index" and data:blog.url != data:blog.homepageUrl)'>
  <!-- item -->
</b:if>
The item will be displayed in the Archive type Page and Index Page, but not on Homepage.

Other operators

Share This

About
Creative Commons License
Blogger Book is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
Misc
Course