Copied to clipboard

Flag this post as spam?

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


  • Chad Rosenthal 272 posts 474 karma points
    Jan 08, 2010 @ 22:31
    Chad Rosenthal
    0

    Help with creating a Macro Parameter Type

     

    I tried to follow the directions from Richard Soeteman's blog http://www.richardsoeteman.net/CommentView,guid,24E1D561-1F6C-4411-BD62-584023D31DF7.aspx#c97c0910-13e7-4d21-88a4-aaae18e44043

    Yet, i seem to be having errors. Well, the issue is that nothing actually happens. I'm using umbraco 4.0.2.1.

    // --------------------------------------------------------------------------------------------------------------------
    // <copyright file="MemberTypePicker.cs" company="">
    //   Optiem, LLC 2010
    // </copyright>
    // <summary>
    //   Defines the MemberTypePicker type.
    // </summary>
    // --------------------------------------------------------------------------------------------------------------------
    
    namespace Optiem.Membership.MacroParameterTypes
    {
        using System;
        using System.Web.UI.WebControls;
        using umbraco.cms.businesslogic.member;
        using umbraco.interfaces;
    
        /// <summary>
        /// MemberTypePicker creates a dropdown list full of the different member types to be used as a parameter type in macros.
        /// </summary>
        public class MemberTypePicker : DropDownList, IMacroGuiRendering
        {
            /// <summary>
            /// Gets a value indicating whether to show the caption.
            /// </summary>
            public bool ShowCaption
            {
                get { return true; }
            }
    
            /// <summary>
            /// Gets or sets the selected value.
            /// </summary>
            public string Value
            {
                get { return this.SelectedValue; }
                set { this.SelectedValue = value; }
            }
    
            /// <summary>
            /// Method runs on load
            /// </summary>
            /// <param name="e">Event Args object</param>
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                if (this.Items.Count == 0)
                {
                    this.Items.Add(new ListItem("Title", "nodeName"));
                    this.Items.Add(new ListItem("Date", "createDate"));
                }
            }
        }
    }
    

    My database entry in the cmsMacroPropertyType table is

    ID: 26

    macroPropertyTypeAlias: memberTypePicker

    macroPropertyTypeRenderAssembly: Optiem.Membership.MacroParameterTypes

    macroPropertyTypeRenderType: MemberTypePicker

    macroPropertyTypeBaseType: String

     

    The value appears when I add a new parameter into the macro, but when I try to add the macro to a template, it doesn't appear. If I change the parameter type to any of the other values, it displays.

    I've tried adding this in both a DLL (where other methods in the DLL are working properly) and by adding the class into the app_Code directory.

    Thanks,

    Chad

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jan 09, 2010 @ 00:07
    Aaron Powell
    0

    Have you had a look into the umbracoLog table to see if there are any messages corresponding with the problem?

  • Chad Rosenthal 272 posts 474 karma points
    Jan 09, 2010 @ 17:29
    Chad Rosenthal
    0

    Nothing in the error log.

  • Chad Rosenthal 272 posts 474 karma points
    Jan 12, 2010 @ 22:54
    Chad Rosenthal
    0

    I took the .cs file out of the old DLL and placed it into it's own project...and now it seems to be working perfectly.

    -C

     

  • Árni Gunnar Ragnarsson 31 posts 51 karma points
    Mar 04, 2010 @ 12:49
    Árni Gunnar Ragnarsson
    0

    I am having problems with this also. I have two controls in the same project, one for displaying a drop down list, the other the exact copy of the numeric control inside Umbraco. Neither work correctly.

    Drop Down List control:
    using System;
    using System.Web.UI.WebControls;
    using umbraco.interfaces;

    namespace Odin.Umbraco.Modules.Selectors {
        public class Destinations : System.Web.UI.WebControls.DropDownList, IMacroGuiRendering {

            string _value = "";

            public bool ShowCaption {
                get { return true; }
            }

            public string Value {
                get {
                    return base.SelectedValue;
                }
                set {
                    this.SelectedValue = value;
                    _value = value;
                }
            }

            protected override void OnInit(EventArgs e) {
                base.OnInit (e);
                this.CssClass = "guiInputTextStandard";
                this.Attributes.Add("style", "width: 30%");
                this.Items.Add(new ListItem("-- select destination --", "0"));
                this.Items.Add(new ListItem("London", "1"));
                this.Items.Add(new ListItem("San Fransisco", "2"));
            }

            public Destinations() {}
        }
    }

    I registered the module like this into the DB:
    insert into cmsMacroPropertyType (
        macroPropertyTypeAlias, macroPropertyTypeRenderAssembly, macroPropertyTypeRenderType, macroPropertyTypeBaseType
    ) values (
        'destinationDropDownList', 'Odin.Umbraco.Modules.Selectors', 'Destinations', 'String'
    )

    I see the parameter type when I go into Developer > Macros > My Macro > Parameters tab. But when I try to put the macro onto a page, the only parameter showing up is the text parameter that ships by default from Umbraco.

    What the hell am I doing wrong ?

    We are evaluating this system, and this is the ONLY thing that I have left on my check-list. If we can do this, we can use the system ...

  • Richard Soeteman 4049 posts 12922 karma points MVP 2x
    Mar 04, 2010 @ 17:39
    Richard Soeteman
    0

    I think that you mixed up Assmebly and typename. Try insert Odin  into  macroPropertyTypeRenderAssembly and Umbraco.Modules.Selectors.Destinations  or Odin.Umbraco.Modules.Selectors.Destinations in macroPropertyTypeBaseType

    Hope it helps you,

    Richard

  • Brent Jubinville 7 posts 27 karma points
    Apr 06, 2010 @ 22:46
    Brent Jubinville
    0

    @Arni, I was having the same problem with namespaces.

    Richard is correct. 

    Odin into macroPropertyTypeRenderAssembly

    Umbraco.Modules.Selectors.Destination into macroPropertyTypeRenderType

    Using the fully qualified name in the macroPropertyTypeRenderType column didn't work for me.  I had to separate the assembly from the full namespace.

  • Calle Bjernekull 16 posts 38 karma points
    Apr 20, 2010 @ 20:45
    Calle Bjernekull
    1

    I've just been struggling with this one, and came to this:

    1: Your class must have an empty constructor: eg new Destination(). If you don't have any other constructor you don't need to do this.

    2: You cannot override OnInit, you must override OnLoad to add controls

     

    Also, it's a bit confusing what to register in the database, the render type does not allow you to add the full namespace path.
    So, If your assembly is My.Assembly and your namespace + class is My.Assembly.Controls.EditControl the type should be Controls.EditControl

Please Sign in or register to post replies

Write your reply to:

Draft