Conditions offer a great way to either hide content based on a set of rules or assign layouts based on those same rules. Let's get into it.
How to Create a Custom Rule
The conditions are saved through JSON as
group:condition_rule. The filter will be preceded by
cs_condition_rule and then where the
: is use a
_. It will looked something like this. These can be used by Assignments or Show Conditions.
How to Create a Custom Condition UI
In this example we are going to create the UI that will show up for show conditions UI. Our group is going to be
example which will be store as
It will look similar to this.
|✔||How to reference and store as in DB.|
|✔||Localized title to display in the library and when inspecting the element|
|How to control arguments. Types include |
|The field to use dynamically to control. Follows Cornerstone Controls API.|
How to Create a Custom Assignment UI
Similar to Show Conditions. The difference in Assignments is that you can specifically have a Condition just for post type. Using
global as your type will allow you to set a Condition to be used on all Post Types.
This uses the same configuration as Show Conditions.
An additional step is needed if you are looking to add an assignment to the global context that be used on all layout types. Without it being apart of the
On a Single Layout it will look similar to this.
See something inaccurate? Let us know