Hide menu Last updated: Sep 21 2015

The dynamic content function in Episerver 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 Episerver CMS core and the parsing engine is optimized to improve performance.
  • Uses hashes to make sure only Episerver CMS code can update the contents.
  • Fully adapts ASP.NET functionality.

The Dynamic Content concept was introduced in Episerver CMS before blocks became available. Blocks and dynamic content are somewhat overlapping concepts and we generally recommend blocks where possible. Since Episerver 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. So if you need to insert inline content, for example, the latest company results or a phone number, dynamic content is still the preferred way to do this.

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 Episerver CMS HTML editor.
  • When the page is rendered, Episerver CMS replaces the dynamic content design time markup with the actual HTML output of the dynamic content class or its delegated control.

Comments