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

Try our conversational search powered by Generative AI!

Render block in Xhtml-field

Vote:
 

I have a pretty plain block, with image, link and text. I have tried to drag n drop it to a xhtml field, but all it renders are the block name.

Puff

The block works fine in a content area. 

#89861
Aug 27, 2014 15:10
Vote:
 

What does the source look like in TinyMCE while in edit mode? It should look something like this where the block is inserted:

The important part here is the data-classid and data-contentlink attribute. The block cannot be found if those are missing.

The rendering of the block does not work either if you have the focus inside TinyMCE.

#89867
Aug 27, 2014 20:18
Vote:
 

And by the way, how are you rendering the xhtml property in the template/view? And which base class do you inherit from in your block renderer?

#89868
Edited, Aug 27, 2014 20:19
Vote:
 

The source inside the timy mce editor looks like this:

I render the xhtml property like this:


                
            

And I inherit from the BlockControlBase in my block renderer. I also got the tag "MainBodyStandard" on mu block.

#89888
Aug 28, 2014 9:22
Vote:
 

This is what causing the problem:

EPiServer.Core.PropertyDataCollection.GetHandler = new GetPropertyDelegate(EPiServer.EmailPropertyGetHandler.EmailPropertyHandler);

The EmailPropertyHandler converts mailto inks to links to contact forms. Unfortunatly it also strips the data-contentlink and the data-classid from the:

Is it possible that the GetPropertyDelegate cant hadle the data-tags?

#90068
Sep 01, 2014 17:21
Vote:
 

Hi,

What is EmailPropertyHandler? Is that a third party plugin?

#90069
Sep 01, 2014 18:45
Vote:
 

No, its a custom written method that converts email andresses in mainbody into adresses to contact form.

 public static PropertyData EmailPropertyHandler(string name, PropertyDataCollection properties)
        {   
            if (name.Equals("MainBody")
            {
PropertyData property = properties.Get(name);

//////[Code]/////

Already on the last line there the data-classid and the data-contentlink attributes for the block is gone.

I think it is the same when I use the DefaultPropertyHandler (from EPiServer.Core.PropertyGetHandler).

#90090
Sep 02, 2014 9:31
Vote:
 

Hi, we have the same problem when trying to modify the mainbody on the publishing event.

public virtual void OnPublishing(PageEventArgs ea)
{
    var mainBody = ea.Page.Property["MainBody"].Value;
    // Here is data-classid and data-contentlink gone

We are using Slimresponse and we modify the image tags in the MainBody to achieve responsive images.

This seems to break the block rendering in Xhtml.

#90093
Sep 02, 2014 9:42
Vote:
 

Has anyone found a solution to this problem?

#90672
Sep 16, 2014 9:13
Vote:
 

If you cast the property to a XhtmlString and then use the method .ToInternalString() it seems like you get what you are looking for.

Edit: You may need to cast the property to an XhtmlStringProperty and then the value to a XhtmlString.

#90681
Edited, Sep 16, 2014 10:43
Vote:
 

Thank you Erik!

.ToInternalString() worked!!! :-)

#90685
Sep 16, 2014 10:57
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.