Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Markus 33 posts 58 karma points
    Apr 12, 2011 @ 10:54
    Markus
    0

    Razor sometimes returns DynamicXML instead of string for rich text property

    Hi,

     

    I think the following is a bug in the razor implementation: I have a rich text property using tinyMce. When I enter some text (text, paragraphs, etc) and output with

    @Model.myRichtTextProperty

    everything works fine.

    However, if I enter 2 lines of text and use the unordered list button of tinymce, I get

    umbraco.MacroEngines.DynamicXml

    as output of the above razor instruction.

    The very same content displays correctly when using

    <umbraco:Item field="myRichTextProperty" runat="server"></umbraco:Item>"

    I checked umbraco.config, it contains something like:

    <myRichTextProperty><![CDATA[
    <ul>
    <li>line 1</li>
    <li>line 2</li>
    </ul>
    ]]></
    myRichTextProperty>

     

    As soon as I enter a paragraph before the list, the output is fine. It would seem that Umbraco's razor implementation returns DynamicXml when the content of a property starts with <ul>. This of course makes it impossible to use razor syntax for rich text properties.

    Is this a known bug, or did I miss something? Is there a simple way to handle that, or will I need to implement and call a helper function whenever I'll want to use a rich text property?

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Apr 12, 2011 @ 11:00
    Sebastiaan Janssen
    0

    Do check the umbracoSettings.config file to make sure the scripting node is in there and has all of the elements in there:

        <scripting>
            <razor>
                <!-- razor DynamicNode typecasting detects XML and returns DynamicXml - Root elements that won't convert to DynamicXml -->
                <notDynamicXmlDocumentElements>
                    <element>p</element>
                    <element>div</element>
                    <element>ul</element>
                    <element>span</element>
                </notDynamicXmlDocumentElements>
            </razor>
        </scripting>

    And there's also an extra bugfix upcoming in 4.7.1.

  • Eran Meir 401 posts 543 karma points
    Apr 12, 2011 @ 11:03
    Eran Meir
    0

    you're right, it happens to me too

  • Markus 33 posts 58 karma points
    Apr 12, 2011 @ 11:05
    Markus
    0

    Excellent - I didn't know about that setting. Thanks a lot!

  • Eran Meir 401 posts 543 karma points
    Apr 12, 2011 @ 11:11
    Eran Meir
    0

    i didn't know about it either, too bad this thing ain't documented on a change log when 4.7 released (which doesn't exist)

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Apr 12, 2011 @ 11:13
    Sebastiaan Janssen
    0

    You're right, it should definitely be in the changelog.

  • Tom 713 posts 954 karma points
    Nov 13, 2011 @ 08:15
    Tom
    0

    hi all!

    running 4.7.1 and getting exactly the same issue with this code where staffIntroText is a richtext editor field..

     

      @if(staffMember.HasProperty("staffIntroText") && !string.IsNullOrEmpty(staffMember.staffIntroText.ToString())) {

                <div class="intro-text">

                    @staffMember.staffIntroText

                </div>

            }

     

    I have set up my umbraco config as specified above..

  • Tom 713 posts 954 karma points
    Nov 13, 2011 @ 08:16
    Tom
    1

    ah the pre tag got in the way

Please Sign in or register to post replies

Write your reply to:

Draft