Copied to clipboard

Flag this post as spam?

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


  • Sander van de Pas 74 posts 147 karma points
    Apr 27, 2012 @ 13:26
    Sander van de Pas
    0

    How to add variable as element

    Dynamically I get the languageCode (e.g. nl or en or us) and put this in a variable. After that I want to use this variable as a property from a media item.

    Instead of $media/umbracoFile I need $media/nl or $media/en or $media/uk depending on the languageCode.

    I tried a lot of things but nothing works.

    Here's my code:

    <xsl:variable name="language" select="$currentPage/ancestor-or-self::Home[@isDoc]" />
    <xsl:variable name="languageCode" select="$language/language" />

    <xsl:for-each select="$currentPage/productDownloads/MultiNodePicker/nodeId">
     <xsl:variable name="media" select="umbraco.library:GetMedia(., false())" />
            <li>
    <a href="{$media/umbracoFile}" target="_blank">
    <xsl:value-of select="$media/[$languageCode]" />
    </a>
    </li>
    </xsl:for-each>

    Could someone help me?

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 9x admin c-trib
    Apr 27, 2012 @ 13:32
    Chriztian Steinmeier
    0

    Hi Sander,

    You do that using the name() function:

    <xsl:value-of select="$media/*[name() = $languageCode]" />

    /Chriztian

  • Sander van de Pas 74 posts 147 karma points
    Apr 27, 2012 @ 14:37
    Sander van de Pas
    0

    Problem was the UPPERCASE of the variable languageCode :-(.

    Now it works!

  • 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