Did Document Type Inheritance go away in v14/v15?

I’m no longer able to add a child doc type on a document type using Umbraco 15. Is this something that deliberately got removed?

I sort of remember hearing that everything is moving to compositions, but I can’t find anything about it. Does anyone know if this is deliberate or not? And, if this is something that may be added in the future.

v13

V15

Think they were deprecated in v14, maybe even v9? Can’t remember.

I can definitely recommend compositions instead, a lot more flexible and not as easy to paint yourself in a corner. There seems to be a consensus here as well:

https://discord-chats.umbraco.com/t/18800807/when-to-use-inherited-doc-types

1 Like

I guess that adds more friction to migrating from older versions of umbraco to v15

Though I have had success in the past with consolidating properties into a composition with the attached below.. though not sure how inherited docs expose the common properties :thinking:

 if (_contentTypeService.Get(CompositionsKeys.UniversalWidgetSettings) is not ContentType universalWidgetSettingsComposition)
 {
     if (_contentTypeService.GetContainer(CompositionsKeys.CompositionsParent) is not EntityContainer compositionsContainer)
     {
         compositionsContainer = null;
         _logger.LogWarning("Universal Widget Settings update: Required container not found for Compositions saving in root");
     }
     // create the composition as we don't exist
     universalWidgetSettingsComposition = new ContentType(_shortStringHelper, (compositionsContainer is null ? -1 : compositionsContainer.Id))
     {
         Alias = "universalWidgetSettings",
         Name = "Universal Widget Settings",
         Icon = "icon-settings",
         IsContainer = false,
         IsElement = true,
         Key = CompositionsKeys.UniversalWidgetSettings,
     };

     _contentTypeService.Save(universalWidgetSettingsComposition);
 }

 if (universalWidgetSettingsComposition.PropertyGroups.FirstOrDefault(x => x.Alias == "common") is not PropertyGroup contentPropertyGroup)
 {
     // create the content property group as we don't exist
     contentPropertyGroup = new PropertyGroup(new PropertyTypeCollection(universalWidgetSettingsComposition.SupportsPublishing))
     {
         Alias = "common",
         Name = "Common",
         Type = PropertyGroupType.Group,
         SortOrder = 0
     };
     // Add a new group to the content type
     universalWidgetSettingsComposition.PropertyGroups.Add(contentPropertyGroup);
 }

 var propertyAliasesToConsolidate = new string[] { "alias", "anchorID", "customCssClasses" };
 // loop though all the widgetsettings and remove any props with aliases we are adding to the composition
 // have to do this prior to adding the properties into the composition as umbraco flags duplicate aliases.
 foreach (var contentType in _contentTypeService.GetAll(WidgetSettingsElementsKeys.GetAll().Select(x => x.Value)))
 {
     foreach (var alias in propertyAliasesToConsolidate)
     {
         contentType.RemovePropertyType(alias);
     }

     if (!contentType.ContentTypeComposition.Contains(universalWidgetSettingsComposition))
     {
         contentType.ContentTypeComposition = contentType.ContentTypeComposition.Append(universalWidgetSettingsComposition);
     }

     if (contentType.IsDirty())
     {
         _contentTypeService.Save(contentType);
     }
 }

 // add the new properties to the content PropertyGroup
 if (contentPropertyGroup.PropertyTypes.FirstOrDefault(x => x.Alias == "alias") is not PropertyType aliasPropertyType)
 {
     // create the property as we don't exist
     aliasPropertyType = new PropertyType(_shortStringHelper, textStringDataType)
     {
         Alias = "alias",
         Name = "Alias",
         Description = "Only used for display",
         SortOrder = 0
     };
     contentPropertyGroup.PropertyTypes.Add(aliasPropertyType);
 }

 if (contentPropertyGroup.PropertyTypes.FirstOrDefault(x => x.Alias == "anchorID") is not PropertyType anchorIDPropertyType)
 {
     // create the property as we don't exist
     anchorIDPropertyType = new PropertyType(_shortStringHelper, textStringDataType)
     {
         Alias = "anchorID",
         Name = "Anchor ID",
         Description = "Adds an ID to the widget so it can be used for anchor links",
         SortOrder = 1
     };
     contentPropertyGroup.PropertyTypes.Add(anchorIDPropertyType);
 }
 
 if (contentPropertyGroup.PropertyTypes.FirstOrDefault(x => x.Alias == "customCssClass") is not PropertyType customCssClassPropertyType)
 {
     // create the property as we don't exist
     customCssClassPropertyType = new PropertyType(_shortStringHelper, textStringDataType)
     {
         Alias = "customCssClass",
         Name = "Custom Css Class",
         Description = "Adds these classes to the widget so it can be targeted with custom css",
         SortOrder = 2
     };
     contentPropertyGroup.PropertyTypes.Add(customCssClassPropertyType);
 }

 if (universalWidgetSettingsComposition.IsDirty())
 {
     _contentTypeService.Save(universalWidgetSettingsComposition);
 }

Interesting that this functionality has been removed. I don’t remember seeing it being announced as deprecated though?

Personally, I tend to use inherited/nested DocTypes when I need a variant of an existing DocType:


E.g. a different Landing Page with a different icon and list view.

Easy enough to do with Compositions too, but I wonder how this will affect the upgrade of v13 sites that used inherited DocTypes? Will they un-nest and lose all of their properties? Will it just break? Edit: I posted too early! See Seb’s post below :slight_smile:

1 Like

It will migrate! When upgrading inheritance is preserved as it was before, but you can’t make any new inherited doctypes.

I just tested in v13, you can still make inherited doctypes, so I am pretty confident that was obsoleted in v14.

1 Like

After upgrade :slight_smile:

1 Like

Thank all.

My upgrade from v13 to v15 worked fine, I just ran into this when I needed to make a new child type and got confused.

I ended up using Umbraco deploy to undo the inheritance and change it to a composition- I manually updated the settings files and ran an import and every seems to be working.

2 Likes

Document Type inheritance is coming back in Umbraco 16:

4 Likes

Excellent news. I’ll wait another day and pull the release candidate; hopefully the migration from broken 15 to 16 will fix my issue :slightly_smiling_face:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.