Content Models

As you have seen in the page models section, page models define properties that are sections of content. They are displayed as different tabs in the back office user interface. To be a valid section property, the type has to be of IContentModel or an ICollection (interface or concrete class) thereof. A content model class is a simple POCO class that implements the IContentModel interface. Content models can themselves contain properties with nested content models (or collections). Below is an example of what a content model could look like.

public class ArticleContent: IContentModel
{
    public string Title { get; set; }

    public string IntroText { get; set; }

    [Shared]
    public ImageContent Image { get; set; }

    public BaseModuleContent Modules { get; set; }
}

...

Inheritance

You can inherit a content model from another (base) content model. The derived content model will inherit all properties from the base class, and add its own properties. The following model will have all the properties of the ArticleContent model, and adds a string property.

public class CategorizedArticleContent: ArticleContent
{
    public string CategoryName { get; set; }
}

Attributes

Content models and properties can be decorated with a number of attributes that change the behavior of the model. All attributes are optional, and default configuration will be set by convention. See the attribute guides for detailed instructions.

Content attributes

The following attributes can be applied to a content model (class).

Property attributes

There are many attributes that can be applied to properties to change property editor behaviour. Most of these attributes only apply to certain property types, and cannot be used for all content properties. See the property editor guide for those editor-specific attributes. The following attributes can be applied to any content property, and are not specific to the property type.