Rendering Conditions (conditional displaying)
Setting location:
- Global Settings - No
- Template Settings - No
- Module Settings - Yes
Overview
Builderius has a visual conditions builder. A specific module will be or will not be rendered based on these conditions. If the module will not be rendered, then its HTML element plus its CSS will not be present in the final HTML output of the template.
A perfect use case would be to restrict content to logged-in users or users with a certain role (e.g., membership sites, user profiles).
How to use
In the visual conditions builder we can add groups of conditions and single conditions (rules). At least one group
of conditions must be evaluated to true
in order to display a module. All conitions must be evaluated to true
inside a group of conditions. In other words, there is an OR relationship between condition groups and an
AND relationship between conditions inside a set.
First, we click on "+ Add group" button (1) to create a new group of conditions. Then we can create a new rule inside this group (2) or delete an existing rule (3) or click on "+ Add group" button again to add a new group.
Example of using standard condition properties
Each condition is a set of three properties: a key, a comparison operator and a value. We have pre-created many properties-keys in advance. It is enough to select them, select the operator and the value.
In the example above the condition means that the module will be shown if the current post ID is equal to the one of "Hello world" post.
Example of using dynamic data properties
In order to make conditions more flexible, we have a special mode "Dynamic data", so that both key and value of the condition can be any dynamic or static data or their mix.
In the example above the condition means that the module will be shown if the current post ID is equal to value
11
. The key is a dynamic data and the value is added as a static value in this case.
Example of using an expression (advanced)
This is an advanced functionality for 100% flexibility of using conditions. We can use an expression here. The result of evaluation of expression mus tbe true or false.
Rendering conditions visual indicator
We can see an "eye" icon next to the module label in the Structure:
This icon indicates we have rendering conditions for the module. The green "eye" icon means the conditions
are currently fulfilled and the module is shown. The red "eye" icon means the conditions for that module are
being evaluated to false
at the moment, so the module is hidden in the builder mode, we can not see it.