Area: Optimizely CMS
Applies to versions: 10-11
Other versions:
ARCHIVED This content is retired and no longer maintained. See the version selector for other versions of this topic.

Dynamic content (Legacy)

Recommended reading 

Note: Dynamic content is deprecated. Use blocks instead. While existing solutions will continue to work, you should not build new solutions on this API. It will be phased out in the future.

The dynamic content function in Optimizely lets developers create functionality in code which an editor can use in the HTML editor.

A Dynamic Content class does not define a whole page rather just a small section of it, making it suitable for smaller functionality which will be inserted inline into texts on the site by the editor. A user control (such as a .NET UserControl) implements the user interface part of a dynamic content object. 

Recommendations for usage

Dynamic Content has the following advantages:

  • Lets the developer render the contents with any .NET-derived type of control directly into texts written by an editor.
  • Dynamic Content is integrated with the Optimizely CMS core and the parsing engine is optimized to improve performance.
  • Uses hashes to make sure only Optimizely CMS code can update the contents.
  • Fully adapts ASP.NET functionality.

The Dynamic Content concept was introduced in Optimizely CMS before blocks became available. Blocks and dynamic content are somewhat overlapping concepts and we generally recommend blocks where possible. Since Optimizely CMS 7.5, it is possible to drag and drop a block into a rich text area which makes it possible to use the block as a "dynamic content" in the text. The main limitation with blocks in rich text is that this is always treated as a block level element. Dynamic content can be treated as either an inline or block element.

Dynamic Content has functionality to auto-generate an editor for the settings for dynamic content. This still uses the editing system that was used in Episerver CMS 6; this system has some limitations that you should be aware of if you want to use the automatic editing functionality:

  • The media system introduced in Episerver 7.5 is not supported. This means that it is not possible to automatically create editors to select a file, for example, an image.
  • Also, the editor that is used is an older version of Tiny MCE that might work slightly different than the main Tiny MCE editor. One example is that this is not upgraded to fully support Internet Explorer 11. Another drawback is that you cannot link to a file in the media system inside the HTML editor.
  • There is no support for new content types introduced in Episerver 7 and above, for example, Content Areas.

These limitations are only valid when you are using the auto-generated user interface. You can always create your own editorial user interface for your dynamic content to overcome most of these limitations.

Developing dynamic content

When you develop dynamic content, consider the following:

  • Create a .NET class that implements the IDynamicContentControl (contains Web Forms specific methods) or IDynamicContentView (for both MVC and WebForms) interface.
  • Register the dynamic content type using either the DynamicContentPlugIn attribute or by registering it in the web.config.
  • The editor creates an instance of the dynamic content class, sets its properties and places it as desired in the Optimizely CMS HTML editor.
  • When the page is rendered, Optimizely CMS replaces the dynamic content design time markup with the actual HTML output of the dynamic content class or its delegated control.
Do you find this information helpful? Please log in to provide feedback.

Last updated: Jun 14, 2021

Recommended reading