Copied to clipboard

Flag this post as spam?

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


  • Max 14 posts 44 karma points
    Apr 06, 2012 @ 16:42
    Max
    0

    Get all tags from RTE with xsl:for-each

    Can I somwhow get specific tags from RTE field (the same way like I do with XML)?

    For example, if I have RTE field "myRTE" with HTML:
    <p>first line</p>
    <p>second line</p>

    How can I do something like:
    <ul>
    <xsl:for-each select="$currentPage/myRTE/p">
    <li><xsl:value-of select="."/></li>
    </xsl:for-each>
    </ul>

    Is that possible?

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Apr 06, 2012 @ 20:07
    Chriztian Steinmeier
    1

    Hi Max,

    Because of the way Umbraco stores RichText content, you need to perform some trickery - I wrote a longer article about this here, which I'd recommend you took a look at.

    /Chriztian

  • Max 14 posts 44 karma points
    Apr 06, 2012 @ 21:57
    Max
    0

    Hi Chriztian!

    Thank you for your reply! I will take a look at your post closer, but quick view seems to me a little bit complicated...

    I thought about something, like:
    - $replace = Replace('myRTE', '&gt;', '&gt;|')
    - $split = Split($replace, '|')
    - For-each($split/value) {...}

    Something like this...
    I did it with "Textbox" field, but don't know, what is the best (more or less the same) way with "RTE" field

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Apr 09, 2012 @ 22:08
    Chriztian Steinmeier
    0

    Hi Max,

    You can absolutely do it like that (using string manipulation/RegEx) - but then should definitely create an extension method for it; First of all: It's really C# programming style which is not at all easily replicated with XSLT constructs, and second: You're gonna need to change that method a lot of times, but that's all implementation details the "view" shouldn't need to care about - all you want in the XSLT is something simple like:

    <xsl:value-of select="MyLib:FormatRTE(myRTE)" />

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft