London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Loading...
Area: Optimizely CMS
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Introduction

This document contains an example of how to create a dynamic content plug-in by implementing the IDynamicContentView interface.

Example

For convenience we inherit DynamicContentBase which implements IDynamicContentBase for us, we then add IDynamicContentView which supports both MVC and Web Forms.

Note that this example makes use of the DynamicContentPlugIn attribute, but only for registering the plug-in. The DynamicContentPlugIn can also be used on an User Control without implementing any interfaces.
C#
using System;
using System.IO;
using EPiServer.Core;
using EPiServer.DynamicContent;

namespace CodeSamples.DynamicContent
{
    [DynamicContentPlugIn(
        DisplayName = "ClassDynamicContentPlugin",
        Description = "Example of a Dynamic Content plugin as a simple class.")]
    public class ClassDynamicContentPlugin : DynamicContentBase, IDynamicContentView
    {
        public ClassDynamicContentPlugin()
        {
        }

        public void Render(TextWriter writer)
        {
            writer.Write("<div>Hello World</div>");
        }
    }
}

Last updated: Feb 23, 2015