Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Dynamic content in text editor

Vote:
 

Hi!

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>

#79984
Jan 13, 2014 11:02
Vote:
 

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.

#80004
Jan 13, 2014 14:57
Vote:
 

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?

#80005
Jan 13, 2014 15:01
Vote:
 

I think that you can use the IDynamicContentDisplayType interface as described in my blog post http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2011/1/Dynamic-content-with-editor-preview/

#80012
Jan 13, 2014 16:19
Vote:
 

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

#80034
Jan 14, 2014 8:27
Vote:
 

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:
default:
return true; //block

#80035
Jan 14, 2014 8:33
Vote:
 

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.

 

This:

<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.

#80037
Jan 14, 2014 8:50
Vote:
 

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:

[BackingType(typeof(PropertyString))]

#80050
Jan 14, 2014 12:49
Vote:
 

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 :)

#80100
Edited, Jan 15, 2014 8:28
Vote:
 

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.

#80341
Jan 21, 2014 11:51
Vote:
 

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.

#80342
Jan 21, 2014 12:08
Vote:
 

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

#80345
Jan 21, 2014 13:11
Vote:
 

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

#80531
Jan 24, 2014 11:04
Vote:
 

What does your dynamic content plugin return? What properties?

#80532
Jan 24, 2014 11:15
Vote:
 

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

#80535
Jan 24, 2014 12:13
Vote:
 

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.

#80537
Jan 24, 2014 12:18
Vote:
 

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.

#80656
Jan 28, 2014 16:55
Vote:
 

Hi,

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.

#81411
Feb 17, 2014 10:24
Vote:
 

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

#82005
Mar 03, 2014 18:42
Vote:
 

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.

#82022
Mar 04, 2014 13:36
Vote:
 

Bump


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?

#84919
Apr 09, 2014 11:32
Vote:
 

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

#84920
Apr 09, 2014 11:43
Vote:
 

@Joel: Download the code from here https://onedrive.live.com/redir?resid=538A53138A8E1E24!266&authkey=!AHMuu1s-1c1BnHA&ithint=file%2c.zip.

 

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

#84941
Apr 09, 2014 21:49
Vote:
 

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

#84961
Apr 10, 2014 11:19
Vote:
 

Joel. Glad I could help.

#84962
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.