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.
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?
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/
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
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
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.
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))]
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 :)
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.
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.
Linus: That's what I did but it doesn't work. If I use the builtin dynamic content plugin it works as expected.
Can't get it to work with just implementing the interface and returning false.
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.
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.
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.
Joel: Sorry for not answering. If your still intrested I can dig up the code.
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.
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?
I will upload my entire dynamic content to my skydrive. Just need to debrand it.
@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.
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>