I have a need to provide a list of predefined colors for my projects Content Editors to pick when selecting a macro using the Macro Container.
The list of avialable proptery type editors in the Macro Parameters editor is quite limited. Is it possible to alter any of the Umbraco settings to add to this list or do I have to create a new Property Type Editor for this and then specify that it can be used as a Macro Paramter Editor in the manifest?
This is what I've done in the past - unsure what version you're using so there might be a better way.
I create the following class (I"ve called my 'theme' but can call it whatever you like) and place the file in the app_code folder, this produces a pre-populated dropdown list of colours (the value being the colour code) which appears as an available macro parameter type :
NOTE: you need to manually update a table in the database (mentioned also in the code comment)
using System;
using System.Web.UI.WebControls;
using umbraco.interfaces;
namespace website.MacroParameterTypes
{
/*
* Need to also manually update the database:
* Insert into cmsMacroPropertyType(macroPropertyTypeAlias,macroPropertyTypeRenderAssembly,macroPropertyTypeRenderType,macroPropertyTypeBaseType)
* values('theme','website.MacroParameterTypes','Theme','String');
*
* */
public class Theme : DropDownList, IMacroGuiRendering
{
private string _value;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (Items.Count == 0)
{
Items.Add(new ListItem("Teal", "20A7AD"));
Items.Add(new ListItem("Teal Light", "74C0C1"));
Items.Add(new ListItem("Red", "E85129"));
Items.Add(new ListItem("Orange", "F8A81C"));
Items.Add(new ListItem("Green", "85BB5B"));
if (!string.IsNullOrWhiteSpace(_value))
{
var item = Items.FindByValue(_value);
if (item != null)
item.Selected = true;
}
}
}
#region IMacroGuiRendering Members
public bool ShowCaption
{
get { return true; }
}
public string Value
{
get
{
return SelectedValue;
}
set
{
_value = value;
}
}
#endregion
}
}
Thanks for looking, this is melting my brain today!
I do see Ishmail's example and this is pretty much what I'm after, exceptin Umbraco7 there's no cmsMacroPropertyType table! I beleive this is not done with attribute tags :
Approved Color as Macro Parameter Editor
Hi
I have a need to provide a list of predefined colors for my projects Content Editors to pick when selecting a macro using the Macro Container.
The list of avialable proptery type editors in the Macro Parameters editor is quite limited. Is it possible to alter any of the Umbraco settings to add to this list or do I have to create a new Property Type Editor for this and then specify that it can be used as a Macro Paramter Editor in the manifest?
Ben
Hi
This is what I've done in the past - unsure what version you're using so there might be a better way.
I create the following class (I"ve called my 'theme' but can call it whatever you like) and place the file in the app_code folder, this produces a pre-populated dropdown list of colours (the value being the colour code) which appears as an available macro parameter type :
NOTE: you need to manually update a table in the database (mentioned also in the code comment)
Sorry - just realized this probably won't work in umbraco 7
:(
Hi Ismael
Thnaks for great response - unfortunately this is a v7 project but I'm sure I can find some examples of doing this the v7 way
Thanks
Ben
Did you find any Umbraco 7 examples?
I ask a similar question here : our.umbraco.org/forum/umbraco-7/using-umbraco-7/57439-Custom-Partial-View-Macro-parameters-(Umbraco-7)?p=0
Im gettign a 404 clicking that link Danny
Hi Ben,
Whoops, URL Copy Paste fail: http://our.umbraco.org/forum/umbraco-7/using-umbraco-7/57439-Custom-Partial-View-Macro-parameters-%28Umbraco-7%29
Thanks for looking, this is melting my brain today!
I do see Ishmail's example and this is pretty much what I'm after, exceptin Umbraco7 there's no cmsMacroPropertyType table! I beleive this is not done with attribute tags :
But I can't even get any example to show up!
is working on a reply...