Copied to clipboard

Flag this post as spam?

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


  • Jonas Eriksson 930 posts 1825 karma points
    Jan 30, 2010 @ 16:59
    Jonas Eriksson
    0

    Parse textrows (separated with line breaks) as items

    Hi!

    I have a textbox multiple where the editors are supposed to enter textlines with ordinary line breaks. Is there some way I can split the rows transforming them to <ul><li>'s, like this?

    "First row
    Second row
    Third row"

    to

    <ul><li>First row</li><li>Second row</li><li>Third row</li></ul>

    Can I do this without c#?

    Regards / Jonas

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jan 30, 2010 @ 17:58
    Morten Bock
    0

    It is without doubt easier to do this from C# that in xslt. But you can try if you can get the umbraco.library.Split(string StringToSplit, string Separator) method to split on the linebreaks by using "\r\n" or "\n" as a separator. This will get you some xml like

    <values>
        <value>blah1</value>
        <value>blah2</value>
    </values>

     

  • Jonas Eriksson 930 posts 1825 karma points
    Jan 30, 2010 @ 20:26
    Jonas Eriksson
    0

    Brilliant!

    <xsl:variable name="splitted" select="umbraco.library:Split($currentPage/data [@alias = 'MyTextboxMultiple'],'&#x0A;')"/>
    <ul>
    <xsl:for-each select="$splitted/value">
    <li><xsl:copy-of select="."/></li>
    </xsl:for-each>
    </ul>

    Thanks Morten

  • 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