Macro Parameter Editors
Every macro can contain parameters. There are some useful default types. For example:
- True/False
- TextBox
- TextArea
- Numeric
- Media Picker
- Content Picker
... and some 'others'. Consult the Backoffice documentation for general information on Macros.
You can create your own custom macro parameter types.
Creating your own macro parameter type
If you want to create a new macro parameter editor you will need some c# programming and database knowledge.
First create a class deriving from a WebControl
and implement the IMacroGuiRendering
interface. Afterwards, open your database editor. Find the cmsMacroPropertyType table and add the new property editor.
IMacroGuiRendering Interface
You can find this interface in the umbraco.interfaces
namespace contained in the interfaces dll. You will need to reference this DLL if you are developing your control in a separate project.
This interface implements 2 properties: Value
and ShowCaption
.
The value stores a string and the ShowCaption property a bool.
Database update
id | macroPropertyTypeAlias | macroPropertyTypeRenderAssembly | macroPropertyTypeRenderType | macroPropertyTypeBaseType |
---|---|---|---|---|
28 | myNewPickerType | NameOfAssembly | FullName.OfType.IncludingNamespace | String |
Example
A very basic example deriving from a DropDownList ASP.NET server control
public class MyCustomPicker : DropDownList, IMacroGuiRendering
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if(this.Items.Count == 0)
{
// set properties
this.SelectionMode = ListSelectionMode.Multiple;
// load data
...
}
}
public bool ShowCaption
{
get { return true; }
}
public string Value
{
get { return this.SelectedValue; }
set { this.SelectedValue = value; }
}
}
Further information
- A nice blog post by Richard Soeteman: Create A Custom Macro ParameterType