Latest news, food, business, travel, sport, Tips and Tricks...

Blogger Logical Operator

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

OperatorMeaningDefault syntax
andANDboolean && boolean
&&boolean and boolean
orORboolean || boolean
||boolean or boolean
notIs not!boolean
!not boolean
Functional SyntaxOperand 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.

,