Copied to clipboard

Flag this post as spam?

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


  • Guy Pucill 23 posts 73 karma points
    Apr 14, 2012 @ 10:04
    Guy Pucill
    0

    How to use GetDictionaryItem with variable

    This works but is static:  <xsl:variable name="farve_1" select="umbraco.library:GetDictionaryItem('Red')"/> <!-- Gives me 'Rød' --> 

    Now i am trying to dynamically parse the correct lookup string into my GetDictionaryItem xsml. But am getting nothing in return. Do i need to change the data type of my variable? Below is my testing so far.

            <xsl:variable name="farve_2" select=".//fields/flowercolor//value"/> <!-- Gives me '#Red' -->
            <xsl:variable name="farve_3" select="umbraco.library:GetDictionaryItem('$farve_2')"/> <!-- Gives me '' -->
            <xsl:variable name="farve_4" select="translate($farve_2, '#','')"/> <!-- Gives me 'Red' -->
    <xsl:variable name="farve_5" select="umbraco.library:GetDictionaryItem('$farve_4')"/> <!-- Gives me '' -->

    Thanks

  • Peter Nielsen 149 posts 206 karma points
    Apr 14, 2012 @ 10:25
    Peter Nielsen
    0

    Hi,

    Try removing the ' in the last one. Like this:

    <xsl:variable name="farve_5" select="umbraco.library:GetDictionaryItem($farve_4)"/>

    /Peter

  • Guy Pucill 23 posts 73 karma points
    Apr 14, 2012 @ 10:56
    Guy Pucill
    0

    Thanks Peter :-)

    <xsl:variable name="farve_1" select=".//fields/flowercolor//value"/> <!-- Gives me '#Red' -->
    <xsl:variable name="farve_2" select="translate($farve_1, '#','')"/> <!-- Gives me 'Red' -->
    <xsl:variable name="farve_3" select="umbraco.library:GetDictionaryItem($farve_2)"/> <!-- Gives me 'Rød' -->

    I ended up doing it like this:

    <xsl:variable name="farve_1" select="umbraco.library:GetDictionaryItem(translate(.//fields/flowercolor//value, '#',''))"/><!-- Gives me 'Rød' -->

  • Peter Nielsen 149 posts 206 karma points
    Apr 14, 2012 @ 11:02
    Peter Nielsen
    0

    Yep... That was what I would say next to do :-)

Please Sign in or register to post replies

Write your reply to:

Draft