Elements Definitions > rules

Currently, rules let you achieve two things :

  • Enable or disable a property (and its associated interface element) when a property is set to some value.

  • Exclude the item(s) of a popup button when a property is set to some value.

Example 1

elements/set/default/li.tpl :
<!-- First property -->
<prop id="type" type="popup">
 <caption>List Item type : </caption>
 <item id="normal">Normal</item>
 <item id="document">Document</item>
 <item id="idea">Idea</item>
</prop>
 
<!-- Second property -->
<!-- Notice the show="false" : the text input will be hidden by default -->
<prop id="comment" type="textInput" show="false">
 <caption>Comment :</caption>
</prop>
 
<!-- Third property -->
<prop id="important" type="checkbox">
 <caption>Is important</caption>
</prop>
 
<!-- Rules -->
<rules>
 <!-- Enable the hidden comment text input when the property with id="type"
      is set to "document" -->

 <ifequal prop="type" value="document">
   <include prop="comment" />
 </ifequal>
 <!-- Disable the "important" checkbox when the property with id="type"
      is set to "idea" -->

 <ifequal prop="type" value="idea">
   <exclude prop="important" />
 </ifequal>
</rules>

Example 2

elements/set/default/li.tpl :
<!-- First property -->
<prop id="type" type="popup" redraw="true">
 <caption>Image Group type : </caption>
 <item id="normal">Normal</item>
 <item id="sticky">Sticky</item>
</prop>
 
<!-- Second property -->
<prop id="align" type="popup">
 <caption>Align : </caption>
 <item id="left">Left</item>
 <item id="center">Center</item>
 <item id="right">Right</item>
</prop>
 
<!-- Rules -->
<rules>
 <!-- Disable "center" and "right" items in "align" property if
      "type" property is set to "sticky" -->

 <ifequal prop="type" value="sticky">
   <exclude prop="align" item="center" />
   <exclude prop="align" item="right" />
 </ifequal>
</rules>