Copied to clipboard

Flag this post as spam?

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


  • Michael Lawrence 128 posts 200 karma points
    Mar 25, 2011 @ 03:11
    Michael Lawrence
    0

    Odd behavior with content from a rich text editor

    This is strange. When the only content of a rich text editor is a list like:

    <ul>
        <li>Item 1</li>
        <li>Item 2</li>
        <li>Item 3</li>
    </ul>

    And I try to just output the content like so:

    <umbraco:Macro runat="server" language="razor">
        @foreach (dynamic n in Model.Career) {
            <div class="current-opening">      
                <h3>@c.Name</h3>
                @c.content
            </div>
        }
    </umbraco:Macro>

    It outputs "umbraco.MacroEngines.DynamicXml" instead of the content. However, if the content in the rich text editor starts with a <p> tag, it outputs the content as HTML like expected.  Why is this?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 25, 2011 @ 03:24
    Tom Fulton
    0

    Hi Michael,

    Don't know the exact reason, but have you tried using Html.Raw?  ie:

    @Html.Raw(c.content.ToString())

    See this similar thread

    -Tom

  • Michael Lawrence 128 posts 200 karma points
    Mar 25, 2011 @ 03:30
    Michael Lawrence
    0

    Yep, it produces the same exact thing.

  • Alex 78 posts 136 karma points
    Mar 25, 2011 @ 11:04
    Alex
    1

    That definitely doesn't seem right, you can get it round it by doing something similar to this.

    @using umbraco.MacroEngines
    @if (Model.BodyText is DynamicXml)
    {
      @Html.Raw(Model.BodyText.ToXml());
    }
    else
    {
      @Model.BodyText;
    }

    or you could use GetProperty("bodyText")

  • Michael Lawrence 128 posts 200 karma points
    Mar 25, 2011 @ 20:04
    Michael Lawrence
    0

    Thanks Alex. Basically I had to do this in order for it to work:

    @Html.Raw(c.GetProperty("content").ToString())

    I'm not sure why it's not working the way it should though. Oh well, time to get a move on with this projects :()

    Thanks!

  • Gareth Evans 143 posts 335 karma points c-trib
    Mar 25, 2011 @ 22:37
    Gareth Evans
    0

    DynamicXML is detecting the markup, there's a few ways to solve it - the easiest is to add ul to the exclude tags list in umbraco.settings

    - i'll do this for the next release

    If the markup is not valid XHTML then it will also work

    The reason the <p> example works is because <p> is an excluded tag

  • Michael Lawrence 128 posts 200 karma points
    Mar 25, 2011 @ 22:39
    Michael Lawrence
    0

    Gotcha, that makes total sense. I didn't even notice that setting in the umbraco.settings. I'll modify it. Thanks so much!

  • Gareth Evans 143 posts 335 karma points c-trib
    Mar 25, 2011 @ 22:43
    Gareth Evans
    0

    Found a bug - should have returned after detecting it was an RTE, fixed in next release

  • Andrei 68 posts 130 karma points
    Jul 04, 2012 @ 10:49
    Andrei
    0

    I'm using 4.7.2 for a new project and I see this bug is still there. Has it been fixed and reintroduced?

  • Gareth Evans 143 posts 335 karma points c-trib
    Jul 04, 2012 @ 22:33
    Gareth Evans
    0

    Did you make the config change in umbraco.settings to include the ul tag?

  • Andrei 68 posts 130 karma points
    Jul 05, 2012 @ 13:36
    Andrei
    0

    Nevermind, it seems to be working, my colleague (new to Razor) misused  the Html.Raw function a bit. Sorry for the trouble..

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies