Skip to content

Operators#


In the Miva Template Language, operators play a crucial role in performing logical, comparison, string manipulation, and mathematical operations. Let’s delve into the various groups of operators and explore examples to understand their functionality.

Comparison Operators#

In the Miva Template Language, operators play a crucial role in performing logical, comparison, string manipulation, and mathematical operations.

Logic Operators#

Logic operators enable you to combine conditions to form logical expressions. The primary logic operators are AND, OR, NOT, and ISNULL. These operators facilitate conditional branching and decision-making in your templates. Here’s an example demonstrating the use of logic operators:

<mvt:assign name="g.color" value="''">
<mvt:if expr="ISNULL(g.color)">
    The variable is NULL.
</mvt:if>

Comparison Operators#

Comparison operators allow you to compare values and expressions, determining their equality, inequality, or relative magnitude. In Miva, comparison operators include the following:

Operator Example Explanation
EQ g.Screen EQ 'SFNT' If the global Screen variable is equal to SFNT, this returns true
NE g.Screen NE 'SFNT' If the global Screen variable is NOT equal to SFNT, this returns true
GT l.settings:product:price GT 15 If the product’s price variable is GREATER than 15, this returns true
LT l.settings:product:price LT 15 If the product’s price variable is LESS than 15, this returns true
GE l.settings:product:price GE 15 If the product’s price variable is GREATER than or EQUAL to 15, this returns true
LE l.settings:product:price LE 15 If the product’s price variable is LESS than or EQUAL to 15, this returns true

String Operators and Concatenation:#

String operators enable you to manipulate strings, performing tasks like substring matching and case-insensitive comparisons. Key string operators in Miva include IN, CIN, and the concatenation operator $.

Math Operators:#

Math operators facilitate arithmetic operations, allowing you to perform addition, subtraction, multiplication, and division. Common math operators in Miva include +, -, *, and /.