I've been trying to create a new custom macro property (a checkbox list) in 4.11.8 following the instructions in Richard's blog (http://www.richardsoeteman.net/2010/01/04/CreateACustomMacroParameterType.aspx).
I have created a new class which implements the IMacroGuiRendering interface, inherits from CheckboxList and exists in a separate assembly sitting in the website's bin.
I have added an entry in the cmsMacroPropertyType table with my assembly name in the macroPropertyTypeRenderAssembly column and my type (minus the assembly name) in the macroPropertyTypeRenderType column.
I can add the property to a macro, but when I try and use it in either the editor or a Macro Picker data type, I'm unable to specify a value for my custom property.
Could you please post the code your'e currently working on? That way it will be easier to see if there is a typo or something else that could be the cause of the issue or make suggestions.
As an update, this error is being thrown when I try and add the macro:
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Umbraco.Core.PluginManager.CreateInstances[T](IEnumerable`1types, BooleanthrowException)
at Umbraco.Core.ObjectResolution.MacroFieldEditorsResolver.GetMacroRenderControlByType(PersistableMacroPropertyprop, StringuniqueId)
at umbraco.editorControls.macrocontainer.MacroEditor.RendeFormControls()
at System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgse)
at System.Web.UI.Page.RaiseChangedEvents()
at System.Web.UI.Page.ProcessRequestMain(BooleanincludeStagesBeforeAsyncPoint, BooleanincludeStagesAfterAsyncPoint)
at System.Web.UI.Page.HandleError(Exceptione)
at System.Web.UI.Page.ProcessRequestMain(BooleanincludeStagesBeforeAsyncPoint, BooleanincludeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(BooleanincludeStagesBeforeAsyncPoint, BooleanincludeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContextcontext)
at ASP.umbraco_editcontent_aspx.ProcessRequest(HttpContextcontext) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\27510986\847481dd\App_Web_editcontent.aspx.5f2dec3.vnl3b665.0.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStepstep, Boolean&completedSynchronously)
The issue was how I had set up the row in the cmsMacroPropertyType table.
Basically, if your assembly is called MyAssembly, and your type exists in the namespace MyAssembly.Namespace.Type then you need to put "Namespace" into the column macroPropertyTypeRenderAssembly and "Type" into the column macroPropertyTypeRenderType.
Creating a Custom Macro Property
Hi,
I've been trying to create a new custom macro property (a checkbox list) in 4.11.8 following the instructions in Richard's blog (http://www.richardsoeteman.net/2010/01/04/CreateACustomMacroParameterType.aspx).
I have created a new class which implements the IMacroGuiRendering interface, inherits from CheckboxList and exists in a separate assembly sitting in the website's bin.
I have added an entry in the cmsMacroPropertyType table with my assembly name in the macroPropertyTypeRenderAssembly column and my type (minus the assembly name) in the macroPropertyTypeRenderType column.
I can add the property to a macro, but when I try and use it in either the editor or a Macro Picker data type, I'm unable to specify a value for my custom property.
Does anyone know what might be going wrong?
Thanks,
Robert
Hi Robert
Could you please post the code your'e currently working on? That way it will be easier to see if there is a typo or something else that could be the cause of the issue or make suggestions.
/Jan
Hi Jan,
Code is as follows:
using System;
using System.Configuration;
using System.Web.UI.WebControls;
using umbraco.interfaces;
using umbraco.NodeFactory;
namespace MacroProperties
{
public class TestimonialPicker : CheckBoxList, IMacroGuiRendering
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Node testimonialHome = new Node(Convert.ToInt32(ConfigurationManager.AppSettings["TestimonialsHome"]));
if (testimonialHome != null)
{
foreach (Node testimonial in testimonialHome.Children)
{
this.Items.Add(new ListItem(testimonial.Name, testimonial.Id.ToString()));
}
}
}
public bool ShowCaption
{
get { return true; }
}
public string Value
{
get
{
return this.SelectedValue;
}
set
{
this.SelectedValue = value;
}
}
}
}
As an update, this error is being thrown when I try and add the macro:
I finally solved this.
The issue was how I had set up the row in the cmsMacroPropertyType table.
Basically, if your assembly is called MyAssembly, and your type exists in the namespace MyAssembly.Namespace.Type then you need to put "Namespace" into the column macroPropertyTypeRenderAssembly and "Type" into the column macroPropertyTypeRenderType.
is working on a reply...