Overriding Template Events
This is an advanced feature that enables you to specify, on each Placeholder Control, a set of actions to execute when the placeholder's control template is executed. This set of actions overrides the actions defined in the control template, and is triggered when any action event defined in the control template occurs. It is therefore possible to define a different set of overriding actions for each placeholder control. In this way a control template can be modified at the placeholder level, separately for each placeholder control. For example, if three placeholder controls use a single control template, and you want to modify the control template when it is instantiated by one of the three placeholder controls, then you can define a set of overriding actions on this particular placeholder control.
|Note:||If there are multiple placeholder ancestors of a control template, then, when the control template is triggered, the first ancestor placeholder that has an override defined for it will be executed.|
|Note:||If you want to prevent a control template being overridden by a placeholder that has an override defined for it, then there are multiple placeholder ancestors of a control template, then, when the control template is triggered, the first ancestor placeholder that has an override defined for it will be executed.|
How to override control-template actions
On a Placeholder Control, you can define a set of actions that override the control actions defined in a control template. Do this as follows:
1.Select the Placeholder Control for which you want to modify control-template actions.
2.In the Styles & Properties Pane, go to the placeholder control's properties and click the Additional Options button of its Control Action property (screenshot below). Alternatively, right-click the placeholder control and, in the context menu that appears, select Template Control Event Overrides.
3.In the Actions window that appears, enter the set of actions you want in the Template Control Event pane (see screenshot below).
In the screenshot above, the placeholder control's actions have been modified by means of an If-Then-Else action, as follows:
•If the language of the client device is English, then the control template is executed as usual. This is achieved by adding, to the Then branch, a Template Event Callback action (shown highlighted in the Actions pane at left in the screenshot above). This action simply instantiates the control template.
•If the client language is not English, then a message box is displayed. The Message Box action is added to the Else branch.
In the event that the control template contains more than one control, you can select different actions for each control event by using conditional processing that tests the value of the \$MT_ControlKind or \$MT_ControlName variables.
If you want to prevent the actions of a control in a control template from being overridden by a placeholder's actions, then set the control's Prevent Action Override property to true (see screenshot below). This property is also available for placeholders in a control template.
Note that the Prevent Action Override property is available only for controls and placeholders in control templates. Its default value is false, and it determines whether any overrides defined on placeholders that use the control template will be overridden or not.