It is currently Sun Jan 29, 2023 3:22 pm

Blogger Logical Operator

Blogger Logical Operator

Post: #1

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.

Login

|

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 239 on Mon Dec 26, 2022 4:40 am

Statistics

Total posts 4 • Total topics 3 • Total members 1 • Our newest member admin