Copied to clipboard

Flag this post as spam?

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


  • Ben Fidge 16 posts 60 karma points
    Aug 25, 2014 @ 13:12
    Ben Fidge
    0

    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

     

  • Ismael 71 posts 354 karma points
    Aug 26, 2014 @ 00:34
    Ismael
    0

    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)

    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
        }
    
    }
  • Ismael 71 posts 354 karma points
    Aug 26, 2014 @ 00:42
    Ismael
    0

    Sorry - just realized this probably won't work in umbraco 7 

    :(

  • Ben Fidge 16 posts 60 karma points
    Aug 26, 2014 @ 10:09
    Ben Fidge
    0

    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

  • Danny Blatant 91 posts 358 karma points
    Oct 17, 2014 @ 17:43
    Danny Blatant
    0

    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

  • Ben Fidge 16 posts 60 karma points
    Oct 17, 2014 @ 18:27
    Ben Fidge
    0

    Im gettign a 404 clicking that link Danny

  • Danny Blatant 91 posts 358 karma points
    Oct 17, 2014 @ 18:54
    Danny Blatant
    0

    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 :

    [PropertyEditor(Alias, "Display Name", EmbeddedResource.RootUrl + "path/markup.html", ValueType = "TEXT")] 
    

    But I can't even get any example to show up!

Please Sign in or register to post replies

Write your reply to:

Draft