Copied to clipboard

Flag this post as spam?

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


  • BenH 59 posts 199 karma points
    Jan 08, 2015 @ 23:44
    BenH
    0

    reformatting text (tags) to something else

    I have a lot of tags ~60 that are all lowercase with no spaces.  I want to display the tags on the site in a nicely formatted box with proper capitalization and spaces in the words.  

    Example:

    URL/?filter=tagone,tagtwo,tagthree is my url that I pull the parameter from and display my nodes that match those.  

    I just want to have those tags display under the matches like Tag One, Tag Two, Tag Three.  Would I use template-match or just variables and if statements? 

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jan 09, 2015 @ 00:32
    Chriztian Steinmeier
    2

    Hi BenH,

    I'd probably do it using a lookup XML variable, to map the URL values to their display values, something like this:

    <xsl:variable name="filter" select="umbraco.library:RequestQueryString('filter')" />
    <xsl:variable name="tagsFromFilter" select="umbraco.library:Split($filter, ',')/value" />
    
    <!-- Map between URL values and display values -->
    <xsl:variable name="tagsProxy">
        <tag id="tagone">Tag One</tag>
        <tag id="tagtwo">Tag Two</tag>
        <tag id="tagthree">Tag Three</tag>
    </xsl:variable>
    <xsl:variable name="tags" select="msxml:node-set($tagsProxy)" />
    
    <xsl:template match="/">
        <xsl:for-each select="$tagsFromFilter">
            <xsl:value-of select="$tags/tag[@id = current()]" />
            <xsl:if test="not(position() = last())">, </xsl:if>
        </xsl:for-each>
    </xsl:template>
    

    Hope that gets you on the right track,

    /Chriztian

  • BenH 59 posts 199 karma points
    Jan 09, 2015 @ 15:36
    BenH
    0

    Thank you Chriztian! Works perfectly.  You rock! 

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jan 09, 2015 @ 15:43
    Chriztian Steinmeier
    0

    Awesome :)

Please Sign in or register to post replies

Write your reply to:

Draft