Shared attribute

API Reference: SharedAttribute Class

The SharedAttribute can be applied to page and content model properties, that are a content model themselves (i.e. implement IContentModel). Without this attribute, the property is considered nested content. Apply this attribute to the property to specify that it is shared content, which can be selected from a content library.

IMPORTANT: Even though a property can easily be configured as either shared or nested by adding or removing this attribute, the content data is saved to the data store in a significantly different way. Removing or adding this attribute to a property for will result in loss of data when existing content is saved!.

Usage

Decorate the property class with the SharedAttribute. The attribute does not have any parameters.

Default Convention

If SharedAttribute is not specified on a property of type IContentModel, this property will be treated as embedded/nested content instead of shared content.

Example

public class SampleContent: IContentModel
{
    // A collection of shared images from the content/media library.
    [Shared]
    public List<Image> ImageGallery { get; set; }

    // A re-useable content item that can be selected from a content library.
    [Shared]
    public PersonDetails Manager { get; set; }

    // This is NOT shared content, and will therefore be saved as embedded data which is not available for re-use in any content library.
    public SeoContent SEO { get; set; }
}