diff --git a/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicBackingItem.cs b/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicBackingItem.cs index e9a1e5362b..1f3e7b5d4a 100644 --- a/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicBackingItem.cs +++ b/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicBackingItem.cs @@ -78,7 +78,7 @@ namespace umbraco.MacroEngines } } - public IProperty GetProperty(string alias) + public PropertyResult GetProperty(string alias) { if (IsNull()) return null; if (Type == DynamicBackingItemType.Content) @@ -91,13 +91,13 @@ namespace umbraco.MacroEngines } } - private IProperty GetPropertyInternal(string alias, INode content) + private PropertyResult GetPropertyInternal(string alias, INode content) { bool propertyExists = false; var prop = content.GetProperty(alias, out propertyExists); if (prop != null) { - return new PropertyResult(prop); + return new PropertyResult(prop) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id }; } else { @@ -106,7 +106,7 @@ namespace umbraco.MacroEngines prop = content.GetProperty(alias.Substring(0, 1).ToLower() + alias.Substring((1)), out propertyExists); if (prop != null) { - return new PropertyResult(prop); + return new PropertyResult(prop) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id }; } else { @@ -129,20 +129,20 @@ namespace umbraco.MacroEngines } if (result != null) { - return new PropertyResult(alias, string.Format("{0}", result), Guid.Empty); + return new PropertyResult(alias, string.Format("{0}", result), Guid.Empty) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id }; } } } } return null; } - private IProperty GetPropertyInternal(string alias, ExamineBackedMedia content) + private PropertyResult GetPropertyInternal(string alias, ExamineBackedMedia content) { bool propertyExists = false; var prop = content.GetProperty(alias, out propertyExists); if (prop != null) { - return new PropertyResult(prop); + return new PropertyResult(prop) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id }; } else { @@ -151,7 +151,7 @@ namespace umbraco.MacroEngines prop = content.GetProperty(alias.Substring(0, 1).ToLower() + alias.Substring((1)), out propertyExists); if (prop != null) { - return new PropertyResult(prop); + return new PropertyResult(prop) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id }; } else { @@ -172,36 +172,51 @@ namespace umbraco.MacroEngines } if (result != null) { - return new PropertyResult(alias, string.Format("{0}", result), Guid.Empty); + return new PropertyResult(alias, string.Format("{0}", result), Guid.Empty) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id }; } } } } return null; } - public IProperty GetProperty(string alias, out bool propertyExists) + public PropertyResult GetProperty(string alias, out bool propertyExists) { if (IsNull()) { propertyExists = false; return null; } + PropertyResult property = null; + IProperty innerProperty = null; if (Type == DynamicBackingItemType.Content) { - return content.GetProperty(alias, out propertyExists); + innerProperty = content.GetProperty(alias, out propertyExists); + if (innerProperty != null) + { + property = new PropertyResult(innerProperty); + property.ContextAlias = content.NodeTypeAlias; + property.ContextId = content.Id; + } } else { - return media.GetProperty(alias, out propertyExists); + innerProperty = media.GetProperty(alias, out propertyExists); + if (innerProperty != null) + { + property = new PropertyResult(innerProperty); + property.ContextAlias = media.NodeTypeAlias; + property.ContextId = media.Id; + } } + return property; } - public IProperty GetProperty(string alias, bool recursive) + public PropertyResult GetProperty(string alias, bool recursive) { bool propertyExists = false; return GetProperty(alias, recursive, out propertyExists); } - public IProperty GetProperty(string alias, bool recursive, out bool propertyExists) + public PropertyResult GetProperty(string alias, bool recursive, out bool propertyExists) { if (!recursive) { @@ -213,7 +228,7 @@ namespace umbraco.MacroEngines return null; } DynamicBackingItem context = this; - IProperty prop = this.GetProperty(alias, out propertyExists); + PropertyResult prop = this.GetProperty(alias, out propertyExists); while (prop == null || string.IsNullOrEmpty(prop.Value)) { context = context.Parent; diff --git a/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicNode.cs b/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicNode.cs index 9eec1dc211..e75229d937 100644 --- a/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicNode.cs +++ b/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicNode.cs @@ -406,7 +406,9 @@ namespace umbraco.MacroEngines { throw new ArgumentNullException("No node alias or property alias available. Unable to look up the datatype of the property you are trying to fetch."); } - Guid dataType = ContentType.GetDataType(n.NodeTypeAlias, data.Alias); + + //contextAlias is the node which the property data was returned from + Guid dataType = ContentType.GetDataType(data.ContextAlias, data.Alias); if (RazorDataTypeModelTypes == null) { @@ -421,7 +423,12 @@ namespace umbraco.MacroEngines Guid g = RazorDataTypeModelAttribute.DataTypeEditorId; return new KeyValuePair(g, type); }) - .ForEach(item => RazorDataTypeModelTypes.Add(item.Key, item.Value)); + .ForEach(item => { + if(!RazorDataTypeModelTypes.ContainsKey(item.Key)) + { + RazorDataTypeModelTypes.Add(item.Key, item.Value); + } + }); } if (RazorDataTypeModelTypes.ContainsKey(dataType)) { diff --git a/umbraco.MacroEngines.Juno/RazorDynamicNode/PropertyResult.cs b/umbraco.MacroEngines.Juno/RazorDynamicNode/PropertyResult.cs index bc8b179b80..2ba36c7f49 100644 --- a/umbraco.MacroEngines.Juno/RazorDynamicNode/PropertyResult.cs +++ b/umbraco.MacroEngines.Juno/RazorDynamicNode/PropertyResult.cs @@ -57,5 +57,8 @@ namespace umbraco.MacroEngines { return !string.IsNullOrWhiteSpace(Value); } + + public int ContextId { get; set; } + public string ContextAlias { get; set; } } }