diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs index f1937c1c0c..0de97fb987 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs @@ -31,6 +31,8 @@ namespace Umbraco.Core.Models.PublishedContent _propertyTypes = propertyTypes.ToArray(); + IsElement = contentType.IsElement; + InitializeIndexes(); } @@ -166,6 +168,11 @@ namespace Umbraco.Core.Models.PublishedContent return index >= 0 && index < _propertyTypes.Length ? _propertyTypes[index] : null; } + /// + /// Gets a value indicating whether this content type is for an element. + /// + public bool IsElement { get; } + #endregion } } diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs index 7e9b1dfe88..e3723e2221 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs @@ -45,8 +45,9 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters if (string.IsNullOrEmpty(elementTypeAlias)) return null; + // only convert element types - content types will cause an exception when PublishedModelFactory creates the model var publishedContentType = _publishedSnapshotAccessor.PublishedSnapshot.Content.GetContentType(elementTypeAlias); - if (publishedContentType == null) + if (publishedContentType == null || publishedContentType.IsElement == false) return null; var propertyValues = sourceObject.ToObject>();