Guide
Creating Input Parameters
Input parameters enable users of an XSLT function to customize its appearance and behavior, which makes it flexible and highly adjustable.
The values specified in the input parameters can be further used in function calls and the function’s template markup.
For example, if your function outputs a list of items, it may output all of them by default. One way is to limit the number of items to display by editing the function’s template markup. This would be a hard-coded value, which makes your function inflexible in this respect.
The other and better way is to use a variable in the markup that will get its value from an input parameter set by the user of the function.
To add an input parameter to a function:
- Edit an XSLT function.
- On the Input Parameters tab, select List of input parameters.
- Click Add New. The input parameter’s property editor opens on the right.
- Set the parameters properties where required or necessary:
- Parameter name: The name of the parameter. The name is used by the system to identify this parameter. Names must be unique and may not contain spaces and other special characters. Use names like 'Title', 'StartDate', 'LargeImage' etc.
- Label: The text that users should see when specifying a value for this parameter. This is the 'human name' for the parameter.
- Help: Write a short text that tells the user what to do with the parameter.
- Parameter type: The type of this parameter.
- Default value: You can specify a default value for this parameter. If a parameter has a default value, users are not required to specify it when calling the function.
- Test value: When previewing you can test with different input parameter values using this field. If this is left blank, the default value will be used for previews.
- Widget type: You can select which type of input widget (like a textbox) to use when specifying a value for this parameter. Widgets are only available for simple types.
- Position: The position of the parameter. This controls the order of the parameters.
- Click Save.
Figure 7: Input parameters
Now you can refer to the parameter from the function’s template markup.
Please note that the input parameter’s value may be also used as a value for the parameter in a function call. Its type must match that of the parameter of the function called to become available for selection.
Figure 8: Input parameter as a function’s parameter type