Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michele Bartolucci 8 posts 88 karma points
    1 week ago
    Michele Bartolucci
    0

    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

  • marc goodson 556 posts 3381 karma points mvp c-trib
    1 week ago
    marc goodson
    100

    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)

  • Michele Bartolucci 8 posts 88 karma points
    1 week ago
    Michele Bartolucci
    0

    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

  • marc goodson 556 posts 3381 karma points mvp c-trib
    1 week ago
    marc goodson
    0

    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!

  • Steve Milligan 5 posts 71 karma points
    10 hours ago
    Steve Milligan
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft