Copied to clipboard

Flag this post as spam?

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


  • s5bc94rp 3 posts 23 karma points
    Jun 27, 2012 @ 10:52
    s5bc94rp
    0

    Not Looping Correctly

    Hello,

    I have the following XSLT code that is not looping correctly;

     <xsl:for-each select="$sponsorsProfile">
     <xsl:sort select="@nodeName" order="ascending"/>
     <xsl:variable name="media" select="umbraco.library:GetMedia(logo,0)"/>
     <a href="{$sponsorsProfile/uRL}"><img src="{$media/umbracoFile}" alt="{$sponsorsProfile/sponsor}" height="100"/></a>
     </xsl:for-each>

    Currently the image of the logo is being shown correctly, however the URL and the ALT text is only appearing correct for the first node in the list.

    I have the text under the for-each line however I cant seem to get this working.

    Any help would be great.

    Thanks

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Jun 27, 2012 @ 10:58
    Chriztian Steinmeier
    0

    Hi Steven,

    You just need to remove the $sponsorsProfile/ "prefixes" from all the places inside the loop:

    <xsl:for-each select="$sponsorsProfile"> 
        <xsl:sort select="@nodeName" order="ascending"/>
        <xsl:variable name="media" select="umbraco.library:GetMedia(logo, 0)"/>
        <a href="{uRL}"><img src="{$media/umbracoFile}" alt="{sponsor}" height="100"/></a>
    </xsl:for-each>

    /Chriztian

  • Jan-Willem de Bruyn 17 posts 38 karma points
    Jun 27, 2012 @ 10:58
    Jan-Willem de Bruyn
    1

    Hi, you are using the $sponsorsProfile to loop trough and getting the uRL and sponsor from it, this means that you loop through the $sponsorsProfile and each time calling it again for the uRL and sponsor, you can just use 

    <xsl:for-each select="$sponsorsProfile"> 
     <xsl:sort select="@nodeName" order="ascending"/>
     <xsl:variable name="media" select="umbraco.library:GetMedia(logo,0)"/>
     <a href="{uRL}"><img src="{$media/umbracoFile}" alt="{sponsor}" height="100"/></a>
     </xsl:for-each>

    then you will use the one you are currently in like you do with your media

    Hope this helps, Jan-Willem

  • s5bc94rp 3 posts 23 karma points
    Jul 01, 2012 @ 11:43
    s5bc94rp
    0

    Thanks guys, such a simple thing when you look back at it.

Please Sign in or register to post replies

Write your reply to:

Draft