Skip to content

Latest commit

 

History

History
64 lines (49 loc) · 2.29 KB

File metadata and controls

64 lines (49 loc) · 2.29 KB

#Macro Parameter Editors

Every macro can contain parameters. There are a few default types. A few default types are

  • bool
  • contentAll
  • contentPicker
  • tabPicker
  • text
  • textMultiline

... and many others. Consult the Backoffice documentation for general information.

Creating your own macro 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 a 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

idmacroPropertyTypeAliasmacroPropertyTypeRenderAssemblymacroPropertyTypeRenderTypemacroPropertyTypeBaseType
28myNewPickerTypeNameOfAssemblyFullName.OfType.IncludingNamespaceString

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