Using Condition Builder form controls for booleans?

Maurice Mahan asked on January 30, 2018 16:56

Is it possible to use the "Condition builder" form control for the standard Visible field in webparts? I'm putting together a widget/webpart where I want to show/hide it based on macro rules instead of a standard checkbox (or manually writing the macros out in the editor).

Recent Answers


Trevor Fayas answered on January 30, 2018 17:49

Don't need to. Just hit the little black > arrow next to any web part field to bring up a macro editing box, you can put your macro in there that will resolve true or false.

0 votesVote for this answer Mark as a Correct answer

Maurice Mahan answered on January 30, 2018 18:34

Yes I know, but I want to use preset Macro Rules instead if possible. The macro is going to be pretty long and i'm putting it in more than 1 place. I also think it's more readable/organized than writing it out manually.

Also I was able to figure out how to add the condition builder to the visible field. Only problem now is everytime I setup conditions in my widget it always resets back to true/false after saving. Not sure what i'm doing wrong.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on January 30, 2018 18:58

Now I get ya.

Glad you found the visible field in the system properties portion of the web part.

For widgets, one limitation is they don't allow macros outside of the default value set when configuring the widget itself in the widget utility. So you can't add macros by default when adding the widget to the page.

May be possible to add a new field, allow them to enter macros then in the web part code render the macro and disable the display of the widget manually.

Also not sure if you can put a macro in the default value that references a widget property (so the use can set a property which the macro in the default value will I'll in and use), may be worth a shot.

Sadly the one downside to widgets.

0 votesVote for this answer Mark as a Correct answer

Maurice Mahan answered on January 30, 2018 19:43

Hm I see. I tried using webparts instead but I still get the same issue. Here's the steps I did:

  1. In the Form controls application I set the "Condition builder" scope to allow to work for booleans and show the control everywhere
  2. In the Webpart application I selected a random webpart and went to System Properties > Visible field > Set the Form control to Condition builder
  3. Add that webpart to a template and in the Visible field I edit it and make a rule to to "Current month is one of the following: January"
  4. After hitting "Apply" the Visible field resets back to False.

I'm thinking maybe the condition builder control doesn't return an actual boolean? It's originally set to be a Long Text type.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on January 30, 2018 20:04

You may be correct, perhaps the condition builder simply returns the text of the built condition, in which case you would need to clone it and change the value property in the form control to return the resolved value of the condition. What version of Kentico are you in? I can try to take a peak!

0 votesVote for this answer Mark as a Correct answer

Maurice Mahan answered on January 30, 2018 20:13

I'm working on a Kentico v11.0 site. Also thanks for your help so far!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.