Hey @100leiden,
I’d recommend to keep the raw boolean values because while it requires that extra step in the Condition UI, sticking with raw booleans is the better architectural choice for several reasons. Here is the advice on why you should stay the course and how to make it feel less “off”:
1. Inspector UI Consistency (The most important reason)
If you define your parameters using raw booleans (e.g., true or false), Cornerstone automatically maps them to the Toggle control in the Inspector.
-
If you use raw booleans: You get a nice, native on/off switch.
-
If you switch to strings (
"true"/"false"): The Inspector might default to a text input or a dropdown. To get a toggle, you would have to manually configure the control and possibly add logic to map those strings back to a “checked” state, which adds more complexity than it saves.
2. Data Integrity and Future-Proofing
Keeping values as booleans makes your component’s JSON data “Type Correct.” If Themeco ever updates the Condition engine to include a native Boolean selector, your components will be ready for it immediately. If you use strings, you’ll have “stale” data types that don’t match the logic they represent.
3. The “1 vs. 0” Alternative (The Middle Ground)
If the | json_encode syntax feels too verbose, an alternative is to use 1 and 0 as your raw values in the JSON.
-
Pros: You can use the Number rule in Conditions (e.g.,
{{dc:p:my_bool}} is 1). This is often cleaner to read.
-
Cons: You lose the automatic “Toggle” control mapping in the Inspector unless you explicitly define the control type in your parameter settings.
4. Recommendation: The “Ternary” Filter
If you find yourself doing a lot of boolean comparisons, you can use a filter to make the Condition more readable. Instead of json_encode, you can do:
{{dc:p:is_active ? 'active' : 'hidden'}}
Then your condition becomes:
String -> {{dc:p:is_active ? 'active' : 'hidden'}} -> is -> active.
This often feels more “semantic” and easier to read when looking at a long list of conditions.
Hope that helps.