Hi,
I have a requirement to insert some content blocks with a specific look and feel into page content. The content block can have different background colors from an authorized list.
A partial macro was the first thing that came into my mind, and the color picker is absolutely the kind of property editor I need for my macro. Unfortunately the color picker is not one of the allowed property editors so my question is: do I really have to create the custom property editor by duplicating the code for the default color picker? Really there is no other way to do this?
The thing that determines whether a particular property editor can be used as a macro parameter editor, is just a flag in it's package.manifest definition ...
isParameterEditor: true
So you don't need to recreate the entire editor again, instead create a new folder in app_data for your 'SuperMacroEnabledColourPicker' and within that folder create a package.manifest file
propertyEditors: [
{
alias: "SuperMacroEnabledColourPicker",
name: "Super Macro Enabled Colour Picker",
isParameterEditor: true,
editor: {
view: "~/path to the existing view for the approved colour picker"
},
defaultConfig { configPropertyAlias: "defaultConfigValue"}
}
]
When you restart Umbraco it will find this new definition of the Colour Picker, and you will be able to use it as a Macro Parameter, it should function exactly like the existing Colour Picker, because it's using the same view...
You can send the additional configuration that you would normally make via the DataType ui via the 'defaultConfig' option.
regards
Marc
(but yes being able to use a 'Data Type' as a Macro Parameter editor would make life easier)
Hi Mark,
I managed to get things working, my necessity was a color picker for a content block so I had to do a little bit of debugging to find that the defaultConfig had to be populated with an object called items containing a list of pairs id/color.
Thanks for your help!
Michele
Hi, I am trying to do the same thing. I have used Steve code in Umbraco V8 but it doesn't show any colors instead it says "You have not configured any approved colours". Any Ideas?
Approved Color property editor in a Macro
Hi, I have a requirement to insert some content blocks with a specific look and feel into page content. The content block can have different background colors from an authorized list.
A partial macro was the first thing that came into my mind, and the color picker is absolutely the kind of property editor I need for my macro. Unfortunately the color picker is not one of the allowed property editors so my question is: do I really have to create the custom property editor by duplicating the code for the default color picker? Really there is no other way to do this?
Thanks, M
Hi Michele
Kind of!
The thing that determines whether a particular property editor can be used as a macro parameter editor, is just a flag in it's package.manifest definition ...
isParameterEditor: true
So you don't need to recreate the entire editor again, instead create a new folder in app_data for your 'SuperMacroEnabledColourPicker' and within that folder create a package.manifest file
propertyEditors: [ { alias: "SuperMacroEnabledColourPicker", name: "Super Macro Enabled Colour Picker", isParameterEditor: true, editor: { view: "~/path to the existing view for the approved colour picker" }, defaultConfig { configPropertyAlias: "defaultConfigValue"} } ]
When you restart Umbraco it will find this new definition of the Colour Picker, and you will be able to use it as a Macro Parameter, it should function exactly like the existing Colour Picker, because it's using the same view...
You can send the additional configuration that you would normally make via the DataType ui via the 'defaultConfig' option.
regards
Marc
(but yes being able to use a 'Data Type' as a Macro Parameter editor would make life easier)
Hi Mark, I managed to get things working, my necessity was a color picker for a content block so I had to do a little bit of debugging to find that the defaultConfig had to be populated with an object called items containing a list of pairs id/color. Thanks for your help! Michele
Yep it's hard to work out what's exactly required for that defaultConfig, working back from the Data Type UI.
But ace you got it working!
Hi Michele
Did you set up the defaultConfig colors in the package.manifest file? If so, can you give me an example please?
Thanks
Steve
I've worked out how to set up the defaultConfig colors:
{ propertyEditors: [ { alias: "ColorPicker", name: "Macro Color Picker", isParameterEditor: true, editor: { view: "~/Umbraco/Views/propertyeditors/colorpicker/colorpicker.html" }, defaultConfig:{ items: [ "FFFFFF", "000000", "43695b", etc.... ] } } ] }
Hi, I am trying to do the same thing. I have used Steve code in Umbraco V8 but it doesn't show any colors instead it says "You have not configured any approved colours". Any Ideas?
Thanks Qaisar
is working on a reply...