Expressions enhance the capabilities of conditional field connection shortcodes, allowing you to showcase content depending on the value retrieved from the field. For instance, you can create an expression where if the field’s value is less thanDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/beaverbuilder/documentation/llms.txt
Use this file to discover all available pages before exploring further.
2, it will display the text “This field has a value less than 2”. If the value is greater than 2, it will show the text “This field has a value greater than 2”.
By utilizing expressions, you gain the ability to dynamically manage the content displayed, tailoring it based on the specific field values. This approach offers a more versatile and adaptable way to present your content, making it responsive to different scenarios.
Syntax
The syntax for expressions involves an Operator and a Comparison Value, both added as parameters to the conditional field connection shortcode. Theexp= parameter is used to specify the operator, while the value= parameter is used to indicate the comparison value.
Operators
Expression operators offer the ability to execute logical operations on comparison values, enabling you to display content based on the field’s returned value. When dealing with Strings (Text), you have the option to utilize the following operators:equalsnotequalscontains
equalsnotequalscontainsgreatergreaterequalslesslessequals
Equals
The Equals operator (exp='equals') compares the exact text or number provided as the comparison value and verifies if it is identical to the value obtained from the field.
Field Value: Beaver Builder
TRUE: The author’s name is Beaver Builder!
Not equals
The Not Equals operator (exp='notequals') compares the exact text or number provided as the comparison value and verifies if it is not equal to the value obtained from the field.
Field Value: Justin Busa
FALSE: The author’s name is not Beaver Builder!
Contains
The Contains operator (exp='contains') verifies if the comparison value includes similar characters or numbers. For example, if a field has a value of Hello World and the comparison value you’re testing for is ello this will be TRUE.
Post Title: Hello World
TRUE: The post title is Hello World.
Greater
The Greater operator (exp='greater') verifies if the comparison value is greater than the value obtained from the field.
Field Value: 1001
TRUE: my-number-field is greater than comparison value “1000”.
Greater equals
The Greater Equals operator (exp='greaterequals') verifies if the comparison value is greater than or equal to the value obtained from the field.
Field Value: 1000
TRUE: my-number-field is greater than or equals comparison value “1000”.
Less
The Less operator (exp='less') verifies if the comparison value is less than the value obtained from the field.
Field Value: 999
TRUE: my-number-field is less than comparison value “1000”.
Less equals
The Less Equals operator (exp='lessequals') verifies if the comparison value is less than or equal to the value obtained from the field.
Field Value: 1000
TRUE: my-number-field is less than or equals to the comparison value “1000”.
Comparison value
The comparison value represents the value you wish to test against the value of your field. It can be either a string (text) or an integer (number). Thevalue="" parameter is used to specify this comparison value.
Dates
You can perform a comparison value test for a date value as long as it is using the data formatYYYYMMDD. This allows the value to be compared as an integer (number).
Numbers
When using operators such asgreater, greaterequals, less, or lessequals, both the Number field value and the value specified in the comparison value parameter are converted to integers before comparison. However, for equals and notequals, the comparison is made using the exact strings as they are.
For instance, if you are testing whether 377.78 is lessequals 377.77, the result is TRUE because both values are converted to 377 before the comparison occurs, making them equal. Conversely, if you test whether 377.77 equals 377.78, the result is FALSE because the two strings are compared as they are without any conversions.
URLs
When conducting URL tests, any trailing slash is disregarded in both the field value and the comparison value. For instance, whether the URL is provided ashttps://my-website.com or https://my-website.com/, the result will be TRUE as the trailing slash is ignored in the comparison.