Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public partial class TextPage : PublishedContentModel
In the above code:

* The model includes a constructor and static helpers to fetch the content type (`PublishedContentType`) and property type (`PublishedPropertyType`).
* The most important part is the property definition (`Header`), which retrieve values from Umbraco.
* The most important part is the property definition (`Header`), which retrieves values from Umbraco.

You can use helper methods to access content and property types:

Expand Down Expand Up @@ -110,9 +110,13 @@ public partial class TextPage : PublishedContentModel, IMetaInfo

### Inheritance

In addition to composition, content types can have a parent-child relationship. In the Umbraco backoffice, a content type appears underneath its parent.
In addition to composition, earlier versions of Umbraco allowed content types to have a parent-child relationship. In the Umbraco backoffice, a content type appears underneath its parent.

By convention, a content type is always **composed of its parent** and therefore inherits its properties. However, the parent content type is treated differently, and the child content type *directly inherits* (as in C# inheritance) from the parent class.
{% hint style="info" %}
The option to add child content types in the backoffice was removed in v14. Migrated sites may still have the child content types set up. New content types can be inherited through Composition.
{% endhint %}

This type of inheritance is treated differently since the content type is always **composed of its parent**. The child content type *inherits directly* (as in C# inheritance) from the parent class.

If `AboutPage` is a child of TextPage, its generated model would inherit directly from `TextPage`:

Expand Down Expand Up @@ -145,7 +149,7 @@ For more complex customizations, use the full version of [Models Builder](https:

### Custom Model Generation with IModelsGenerator

From Umbraco 11.4, you can implement the `IModelsGenerator` interface hto customize how models are generated. This allows you to replace Umbraco’s default implementation using dependency injection:
From Umbraco 11.4, you can implement the `IModelsGenerator` interface to customize how models are generated. This allows you to replace Umbraco’s default implementation using dependency injection:

The interface can be accessed via `Infrastructure.ModelsBuilder.Building.ModelsGenerator`.

Expand Down