The other day I was searching the web looking for an easy way to add my own dropdown list as a parameter / property on an Umbraco Macro. There are plenty of articles out there, but none with a complete explanation of how to do this easily, within minutes - so here goes!
How To Add A Custom Dropdown Parameter To An Umbraco Macro
Step 1 - Download The Source Code
Download my custom dropdown umbraco macro parameter package from github and place it in your App_Plugins folder like so:-
Step 2 - IISReset
Do an IISReset on your machine to clear down any local Umbraco caching.
Step 3 - Create New Data Type
In your Umbraco CMS back-office > Developer section add a new DataType (in this example I have called mine 'Title Position'), and select the 'Title Position' in the Property editor field:-
Step 4 - Add The Dropdown to Your Macro
You are done! Now just select the new data type when adding a new parameter within your own macro:-
To use the selected value from your custom dropdown umbraco macro parameter use the following razor syntax:-
Model.MacroParameters["TitlePosition"].ToString()
Leave Your Comments...