Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

ContentType attribute

Describes the ContentType attribute, used in Optimizely Content Management System (CMS) to define a set of properties needed when creating content types such as pages and blocks.

Configurable properties

Optimizely Content Management System (CMS) requires the ContentType attribute for all content types. ContentType is in the EPiServer.DataAnnotations namespace and has the following configurable properties.

PropertyDescriptionDefault value
AvailableInEditModeDefines whether you can create content of this type in edit view.true
DescriptionText that describes the function of the ContentType.NULL
DisplayNameThe name shown in edit view for this ContentType.NULL
OrderThe sort order used to determine the ContentType’s position in listings.100
GUIDIdentifier for the ContentType. You can match the code definition to an existing definition in the database.Guid.Empty
GroupNameName for grouping ContentTypes when you display them for selection in edit view.NULL

Access

The optional Access attribute defines which users, roles, and visitor groups have access rights to create content of a specific type in the user interface. Access applies filtering based on this attribute after ordinary access rights on content.

📘

Note

If the Access attribute is not present, any user (who has edit access) can create content of the specific type.

PropertyDescriptionBehavior if not specified
Users, Roles, VisitorGroupsDefines which users, roles, and visitor groups have access rights.No user has access to ContentType.
AccessDefines the level of access to grant.ContentTypes support access level Create only.

The following image shows how CMS maps the attribute properties to settings in admin view.

AvailableContentTypesAttribute

Use AvailableContentTypesAttributes to set which content types are available under a content instance; it has the following configurable properties.

PropertyDescriptionDefault value
AvailabilityDefines whether all or no content types are available. If you set none, other settings on the attribute are ignored.Availability.All
IncludeA type array of typed content to specify which content types are available under a content instance of the type with the attribute.Type[0]
ExcludeA type array of typed content to specify which content types are not available under a content instance of the type with the attribute.Type[0]
IncludeOnStates that the content with this attribute is available under the typed content in the type array.Type[0]
ExcludeOnStates that the content with this attribute is unavailable under any typed content in the type array.Type[0]

The types on Include, Exclude, IncludeOn and ExcludeOn can be typed content directly, or it can be the type of an interface or a base class. Registered types that can be assigned to the specified type are included at registration. For example, if an interface is specified in an Include list, then typed pages that implement the interface are included.

The following image shows how Include differs from IncludeOn and how they are mapped in admin view. 

  • Include excludes typed content except that which is specified.
  • IncludeOn does not exclude any content type for types that have all content types available.

The following image shows how Exclude differs from ExcludeOn and how they are mapped in admin view. 

  • If types are not registered in Include, then registered page types are available except the types in the Exclude specifications.
  • If types are registered in Include, then those types are available except the types in the Exclude specifications.

The following image shows how Availability is mapped to settings in admin view.

ImageUrl

Use the ImageUrl attribute to set the icon for content types. The icon is visible in the user interface when you create content.

PropertyDescriptionDefault value
PathThe path to the icon to use for the page type.NULL