Property types
Describes how to use built-in property types in your models and also create your own property types.
Optimizely Content Management System (CMS) content is built from models with properties that store and present data. Use many built-in property types in your models or create your own.
Most property types work as instance or list properties. Some types are list types themselves; those cannot be modeled as lists.
Common property types
These property types cover the most frequent content modeling needs.
| What you want to create | Property solution | Editing experience |
|---|---|---|
Plain short text – Control the allowed length with the StringLength attribute. Use a custom tag to control the containing tag, such as using an H1 for the main header for the page. | String | One row input |
Plain long text – Control the allowed length with the StringLength attribute. | String with UIHint.Textarea | Text area |
| HTML | XHtmlString | A TinyMCE HTML editor |
Integer value – Controls other rendering, such as the number of items in a list. Control the min and max values with the Range attribute. | Int | A number slider |
Date and time – Control the min and max values with the Range attribute. | DateTime | A date and time picker |
Double – Control the min and max values with the Range attribute. | Double | Check editor |
| Boolean | Boolean | Checkbox |
| Page type – Filter items in a list, and so on. | PageType | |
BLOB – Hold binary data (such as an image). Route to a BLOB with pattern <Url to content>/BlobPropertyName. | Blob |
Work with other content
Reference existing content with Link or LinkCollection to create internal or external links.
ContentAreadisplays content from other content items.ContentReference,ContentReferenceList, orURLlink to a single content item of a specified type.- The
AllowedTypesattribute further restricts the kind of links that can be added to a property (although there are a few known limitations).
ContentReference<T> property type
ContentReference<T> property typeContentReference<T> is a built-in property type that references a single content item of a specified type.
[AllowedTypes(typeof(MyPageType))]
public virtual ContentReference<MyPageType> FeaturedPage { get; set; }
Note
PageReferenceis now obsolete. Always useContentReference<T>for pages, media, or blocks.
Use a content reference with many UI hints to select different entities in CMS, such as a block, a media item, a block folder, or a media folder.
| What you want to create | Property solution | Editing experience |
|---|---|---|
Link to a media file of any type – Link to any file in the media repository. Use ContentReference instead to use standard content rendering. (Mostly for backward compatibility.) | ContentReference with UIHint.MediaFile | Content picker with drag and drop support |
| Link to an image – Lets an editor select content in the media repository by implementing IContentImage. | ContentReference with UIHint.Image | Content picker with drag and drop support |
Link to a video – Lets an editor select content in the media repository by implementing IContentVideo. | ContentReference with UIHint.Video | Content picker with drag and drop support |
Link to a media file with the possibility to append information in the URL – Each link can be an item inside Optimizely CMS, such as pages, media, and external URLs. Use URL instead of ContentReference to add information, such as query string parameters to control size. | Url with UIHint.MediaFile or UIHint.Image or UIHint.Video | Content picker with drag and drop support |
| Content area | ContentArea | |
| URL | Url | Link dialog with drag-and-drop support |
Link to multiple external and/or internal resources – Does not support AllowedTypesAttribute. | LinkItemCollection | Link collection editor with drag-and-drop support |
Link to external or internal resource – Does not support AllowedTypesAttribute. | LinkItem Note: Available in CMS 12.11.0 and later. | Link editor with drag-and-drop support |
Link to multiple internal pages, media files, or other content types – Supports AllowedTypesAttribute. | ContentReferenceList | Content picker with drag and drop support |
Select predefined values
Give editors a constrained set of choices with drop-down and checkbox list properties.
| What you want to create | Property solution | Editing experience |
|---|---|---|
| Select a single item from a relatively short list of options | String/Int with SelectOne attribute | Link to implementation page |
| Select several items from a relatively short list of options | String/Int with SelectMany attribute | Link to implementation page |
| Select a single item from a relatively long list of options. – Use with caution because the auto-suggestion editor creates requests to the server. | String/Int with AutoSuggestion attribute | Link to implementation page |
Validation attributes
Validation attributes enforce data constraints on content properties. CMS supports the following .NET validation attributes:
RangeStringLengthRegularExpressionEmailAttribute
Create custom attributes that implement ValidationAttribute. See Write custom attributes.
Updated 17 days ago
