Try our conversational search powered by Generative AI!

Dynamic content in text editor



In cms 6r2 it was possible to insert dynamic content in the middle of a paragraph in the text editor. Now it seems that it always ends the <p> tag and inserts a new span afterwards. This is bad when you want to have "boiler plates" in text, like a phone number.

Does anyone know if it's possible to get it working like it did previously? I want to be able to instert it in the text editor with the dynamic content fetching a property.

Exmple: <p>Contact us, our phone number is: [dynamic content fetching the phone number from property on startpage]</p>

Jan 13, 2014 11:02

I think that it still should be possible to create inline dynamic content in EPiServer 7/7.5. You need to implement the interface IDynamicContentDisplayType if you create your own dynamic content and want to have that as inline content.

Jan 13, 2014 14:57

I use the built in dynamic content plugin for fetching value from a property on an other page. If I want to display that inline, do I have to create my own dynamic content plug in with the same functionality? Or can I somehow override how it's rendered?

Jan 13, 2014 15:01

I think that you can use the IDynamicContentDisplayType interface as described in my blog post

Jan 13, 2014 16:19

Thanks Linus, I'll look into that!

So just to make clear I understood, if I want it to render it as inline I have to make a new dynamic content module implementing IDynamicContentDisplayType. There is no way to make the built in functionality "Page property" render inline by default?

Problem here is we're upgrading a customers site from 6r2 to 7.5 and they use Dynamic Content "Page property" to insert reusable text on a lot of pages. Today that renders inline by default, but if I were to upgrade it would start rendering as block

Jan 14, 2014 8:27

If you want a specific property to render differently from it's storage type (normally string is inline while long string is block) you need to create a custom property and implement the IDynamicContentDisplayType interface. When inserting the page property dynamic content, we will check if the property that is inserted implements this interface and use this setting. If not, we will fallback to The hardcoded list depending on the storage data type for the property:

case PropertyDataType.String:
case PropertyDataType.Boolean:
case PropertyDataType.Date:
case PropertyDataType.FloatNumber:
case PropertyDataType.Number:
case PropertyDataType.PageReference:
case PropertyDataType.PageType:
return false; //inline
case PropertyDataType.Category:
case PropertyDataType.LinkCollection:
case PropertyDataType.LongString:
return true; //block

Jan 14, 2014 8:33

Hmm, ok. The property I am using is a PropertyDataType.String, so it should according to this render as inline. It does render a <span> tag, but it's not possible to insert it in the middle of a paragraph, as it was previously.

If I in the text editor put the marker mid sentence it ends the current <p> tag, inserts a <span> with the property value and then renders a new <p> with the rest of the content. It's hard to describe what happens but see an example below.



<p>This is our phone number {insert page property here}, call us anytime</p>

Should render as this after i've inserted the page property:

<p>This is our phone number <span>08-123 45 67</span>, call us anytime</p>

But it renders as this

<p>This is our phone number</p>

<span> 08-123 45 67</span>

<p>, Cal us anytime</p>


This can easily be reproduced in the alloy templates by trying to insert another pages title mid sentence using page property dynamic content.

Jan 14, 2014 8:50

I found why you are getting this behaviour. When testing with some built in properties, like Name, it works as expected. When using a custom property, like the MetaTitle property in the Alloy templates, I get the behavior you describe. The reason for this is that we changed the backing type for strings to LongString in EPiServer 7 to not limit the storage to 255 characters. This has the negative side effect that custom string properties are treated as block elements when inserted using the page property dynamic content plug-in. Perhaps this should be changed in the core, but you can do a work around by adding the following attribute to your property to force the backing property type:


Jan 14, 2014 12:49

Thank you! This resolved my issue, and is now working as expected!

I agree though, that the core should be PropertyString, since you can easily choose a backing type of PropertyLongString if more space is needed :)

Edited, Jan 15, 2014 8:28

Im a bit confused here. What do I need to do in order to get our dynamiccontent to render inline in a MainBody property of type Xhtmlstring?

The dynamic content is a normal user control decorated with the DynamicContentPluginAttribute.

Jan 21, 2014 11:51

Implement the IDynamicContentDisplayType interface and return false from the RenderAsBlockElement property.

The answer above was about how to make a property shown in the built in page property dynamic content plug-in to appear inline.

Jan 21, 2014 12:08

Linus: That's what I did but it doesn't work. If I use the builtin dynamic content plugin it works as expected. 

Jan 21, 2014 13:11

Can't get it to work with just implementing the interface and returning false.

Jan 24, 2014 11:04

What does your dynamic content plugin return? What properties?

Jan 24, 2014 11:15

It justs returns a number in string format and set's it to an asp:label. 

Jan 24, 2014 12:13

If you use a property for the number and it's of the string type, don't forget to set backingtype to propertystring. Default is longstring for some reason, and that was the issue for me.

Jan 24, 2014 12:18

I had a usercontrol wich was the presentation control (decorated with dynamicconteplugin attribute. Also had an another usercontrol for custom editing properties. (Dropdown) I couldn't get it to work with just implementing the IDynamicContentDisplayType.

I hade to implement the IDynamicContentView interface aswell. Using the State Property for managing data between presentation and editing control.

Jan 28, 2014 16:55


Per: How did you make it render as inline with the IDynamicContentView interface? I've tried implementing IDynamicContentDisplayType and setting the RenderAsBlockElement to false but it still renders as a block. The property I'm inserting into the control is of the type PropertyString so it's not the same issue as Eric had.

Feb 17, 2014 10:24

Joel: Sorry for not answering. If your still intrested I can dig up the code.

Mar 03, 2014 18:42

Per: No worries! It would be great if you could dig up the code as I still haven't come up with a solution to this problem.

Mar 04, 2014 13:36


Per: Have you managed to find the code that solves this problem for you? :) Or has anyone else found a solution for rendering dynamic content as inline in EPiServer 7?

Apr 09, 2014 11:32

I will upload my entire dynamic content to my skydrive. Just need to debrand it.

Apr 09, 2014 11:43

@Joel: Download the code from here!266&authkey=!AHMuu1s-1c1BnHA&


I removed som code from some method and changed the namespace but it' 99 intact. 

Apr 09, 2014 21:49

Per: Thanks, I solved my problem after looking at your code!

Apr 10, 2014 11:19

Joel. Glad I could help.

Apr 10, 2014 11:32
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.