Copied to clipboard

Flag this post as spam?

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


  • Powellze 38 posts 73 karma points
    Nov 09, 2010 @ 10:58
    Powellze
    0

    How to return an umbraco item in one line from a richtext editor?

    I have an Umbraco:Item which is called gmapMarker which is placed within a javascript file. Within the Document Type it is specified as a Richtext editor.

     

    Problem: the richtext editor allows carriage returns and puts these as <br /> (and some form of encoded carriage return)

    I thought it might be \r\n or even \n as in the escape character for carriage return and line return that would be stored within the db.

    When the output from my umbraco item is returned it as follows:

     var strMarkerInfo = '&lt;p&gt;Hall,&lt;br /&gt;
    Riding,&lt;br /&gt;
    Hull,&lt;br /&gt;
    HU7 1AA&lt;/p&gt;&lt;br/&gt; ';

    The great part of this is that this breaks the javascript! as I need the returned content to be returned in one line.

     

     

    So my question is how do I return an umbraco Item in one line from a richtext editor?

     

    I have seen things like this on the forum but to no avail:

    var strMarkerInfo = '<umbraco:Item field="gmapMarker" runat="server" xslt="concat({0},'&lt;br/&gt; ')" />';

    or

    var strMarkerInfo = '<umbraco:Item field="gmapMarker" runat="server" xslt="concat({0},'&lt;br/&gt; ')" xsltDisableEscaping="true" />';
  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Nov 09, 2010 @ 18:10
    Sebastiaan Janssen
    1

    You're probably best of creating an XSLT extension that replaces \r\n with nothing.

  • bob baty-barr 1180 posts 1294 karma points MVP
    Nov 09, 2010 @ 19:01
    bob baty-barr
    0

    could an xslt entitity work?

    <!ENTITY ntilde  "&#241;" ><!-- small n, tilde -->
  • Powellze 38 posts 73 karma points
    Nov 10, 2010 @ 11:39
    Powellze
    0

    Thanks for all your help to you both. I came across a method called normalize-space.

    This works well for the Richtext Editor although I am not sure what happens behind the scenes but it does remove the carriage returns.

    <xsl:value-of select="normalize-space($currentPage/gmapMarker)" disable-output-escaping="yes" />

    I dont think I can mark this as an answer myself so if anyone wants to post the answer I just did I will happily class it as the solution :)

     

    Thanks Everyone!

Please Sign in or register to post replies

Write your reply to:

Draft