Start page
Start page
Start page

Start page / Template development / Template syntax / Instructions / $CMS_IF / legacyCompare

legacyCompare(...) Available up to FirstSpirit Version 4.0

The comparative operators in a $CMS_IF(...)$ expression differ from each other between FIRSTspirit 3.1 and 4.0.

In FIRSTspirit 4.0 these comparative operators can be used with the help of the "legacyCompare(...)" function.

Important The function can only be used within the condition of a $CMS_IF(...)$ expression.

Important The "legacyCompare(...)" function will be removed in a later FIRSTspirit version .

The function should therefore no longer be used and the expressions should be converted to the FIRSTspirit 4.0 syntax (cf. $CMS_IF(...)$ instructions ).

Syntax of legacyCompare(...)

When using legacyCompare(...) the following syntax must be adhered to:

$CMS_IF(legacyCompare(OBJECT_1, OPERATOR, OBJECT_2))$
...
$CMS_END_IF$
Important All parameters of legacyCompare(...) are mandatory parameters.

Parameters of legacyCompare(...)

legacyCompare(...) has three parameters:

  • OBJECT_1
  • OPERATOR
  • OBJECT_2

OBJECT1 / OBJECT2

The parameters OBJECT1 and OBJECT2 can be an Expression , e.g. a Variable or constant .

OPERATOR

The following keywords can be used for OPERATOR:

OPERATOR

Description

==

The comparison of OBJECT_1 and OBJECT_2 returns true , if OBJECT_1 and OBJECT_2 are identical .

!=

The comparison of OBJECT_1 and OBJECT_2 returns true , if OBJECT_1 and OBJECT_2 are not identical .

contains

The comparison of OBJECT_1 and OBJECT_2 returns true , if OBJECT_1 contains OBJECT_2 .

endsWith

The comparison of OBJECT_1 and OBJECT_2 returns true , if OBJECT_1 ends with OBJECT_2 .

even

The comparison of OBJECT_1 returns true , if OBJECT_1 is even .

The details of OBJECT_2 are ignored. It is recommended that OBJECT_2 should be given as null to make it clear that the value is not taken into account in the comparison.

greaterOrEqualThan

The comparison of OBJECT_1 and OBJECT_2 returns true , if OBJECT_1 is greater than or equal to OBJECT_2 .

greaterThan

The comparison of OBJECT_1 and OBJECT_2 returns true , if OBJECT_1 is greater than OBJECT_2 .

lessOrEqualThan

The comparison of OBJECT_1 and OBJECT_2 returns true , if OBJECT_1 is less than or equal to OBJECT_2 .

lessThan

The comparison of OBJECT_1 and OBJECT_2 returns true , if OBJECT_1 is less than OBJECT_2 .

odd

The comparison of OBJECT_1 returns true , if OBJECT_1 is odd .

The details of OBJECT_2 are ignored. It is recommended that OBJECT_2 should be given as null to make it clear that the value is not taken into account in the comparison.

startsWith

The comparison of OBJECT_1 and OBJECT_2 returns true , if OBJECT_1 begins with OBJECT_2 .

   

Examples of legacyCompare(...)

Several examples of use of the instruction within templates are shown in the following. The examples are intended to clearly show the specific effect of the instruction and provide help for the template developer when creating their own templates.

Important The examples displayed here must be adjusted for use within a project! For example, variable names must be changed to the specific variable names of the project in which the instruction is to be used.

1st Example: Even check

Code example:

$CMS_IF(legacyCompare(3, "even", null))$
Even
$CMS_ELSE$
Odd
$CMS_END_IF$

Description:

In the example the check is whether the constant 3 is even.

Output:

Odd

2nd Example: Even check without legacyCompare(...)

Code example:

$CMS_IF(3.even)$
Even
$CMS_ELSE$
Odd
$CMS_END_IF$

Description:

In the example the check is whether the constant 3 is even.

Output:

Odd

© 2005 - 2012 e-Spirit AG | All rights reserved. | Last change: 16.05.2008