Try our conversational search powered by Generative AI!

Dynamic Content MVC - no edit for properties



Iam trying to create inline dynamic content so iam using the DynamicContent classes rather then blocks. My problem is that all the properties i add in my dynamicContent class are not displayed in edit mode of the dynamicContent. I can make it work using a User Control but i want to only use a model and a cshtml view preferably.

In edit mode:

Any help is much appriciated! Thanks!

Also a bonus question at the end.. What should i look at to create new dynamicContent classes using edit/admin mode or a admin plugin?

May 04, 2016 11:15

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.

If you still want to use dynamic content instead of blocks, you can try the following code:

[DynamicContentPlugIn(DisplayName = "My dynamic content")]
public class MyDynamicContent : DynamicContentBase, IDynamicContentView
    public PropertyString MyProperty { get; private set; }

    public MyDynamicContent()
        MyProperty = new PropertyString();
        Properties = new PropertyDataCollection { { "MyProperty", MyProperty } };

    public void Render(TextWriter writer)
        if (MyProperty != null && MyProperty.Value != null)
            writer.Write("<p>" + MyProperty.Value + "</p>");

May 04, 2016 20:48

As Dejan says, blocks can also be used in tinymce editor and is the new way of doing this. Dynamic content is a dying concept so if possible, stick to blocks. Much easier and more powerful. What's not to like :)

May 04, 2016 23:47

I was able to make my dynamic content with Dejan's example. I missed using the Properties property. And by overriding the "RenderAsBlockElement" property i was able to make it inline.

The reason iam doing this with dynamic content instead of blocks is because the documentation recommends it.

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.

Thanks for you help guys! :)

May 09, 2016 11:38
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.