Blocks in Optimizely Content Management System (CMS) are reusable smaller content parts that editors can add to pages. You also can use blocks in code as a property, which is a convenient way to reuse a set of properties in multiple instances.
Blocks can only be rendered in the context of other content, such as a page. A block instance is either part of a page instance (if a `PageType
` or `BlockType
` contains a property of the block type), or a shared instance. When a block is used as a property on a page, it is stored, loaded and versioned with that page.
## Add a block as a property
Here we assume that you have an existing page type "Standard Page", to which you want to add an existing block type "Teaser Block". The page type has a Main body property of type `XhtmlString
`. The block has a `Heading
` property of type `String
`, and an Image property of type `ContentReference
`.
In the example below, we add the block as a property to the page type, and update the corresponding view for the page type to display the block as a property.
**Example:** The Teaser Block block type.
**Example:** The Standard Page page type with Teaser Block added as a property.
**Example:** The view for the Standard Page.
The result when editing a page based on Standard Page page type in the **All Properties** editing view.

Note
The functionality "Fetch content from another content item" will only apply when a property is considered "Null". For a block property this means that all properties within the block must be null for fetch content to apply. This can be an issue if the block contains a primitive type, such as a bool, nullable bool, int or nullable int, and that has a value. It is currently not possible to set a null value for those properties from the edit UI, meaning that if such a block property has a value it cannot be "nulled" from the user interface to get fetching data to apply. This can be solved by either a custom editor that can set null value as well or by having an event handler to `
IContentEvents.PublishingContent
` and in the event handler set the value to null if it is default value (false for a bool/nullable boolean or 0 for an int/nullable int).