Copied to clipboard

Flag this post as spam?

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


  • David F. Hill 122 posts 242 karma points
    Apr 01, 2010 @ 01:36
    David F. Hill
    0

    Media URLs from a Multiple Media Picker list

    Hello Umbraco Colleagues,

    We have the TreeMultiPicker package installed and used it in a docType to create a list of files (PDFs actually).

    Now we need to create a list of links to those PDFs using XSLT - but I can't get it to work.

    <xsl:variable name="docs" select="$currentPage/data[@alias='documentList']"/>
    <xsl:variable name="splitDocs" select="umbraco.library:Split($docs, ',')" />
    <ul>
    <xsl:for-each select="$splitDocs/value">
    <xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById(.)"/>
    <li>
    <a>
    <xsl:attribute name="href">
    <xsl:value-of select="umbraco.library:GetMedia($currentNode/@id, 0)/data [@alias = 'umbracoFile']"/>
    </xsl:attribute>
    <xsl:value-of select="$currentNode/@nodeName"/>
    </a>
    </li>
    </xsl:for-each>
    </ul>

    The name of the property containing the list of files is "documentList"

    I'm not getting either the umbracoFile nor the nodeName of each file in the list.

    What am I doing wrong?

    David Hill

  • Neil Campbell 58 posts 182 karma points
    Apr 01, 2010 @ 04:29
    Neil Campbell
    1

    Hi David,

    Try the below snippet (Note the umbraco.library:GetMedia call instead of umbraco.library:GetXmlNodeById). I have also added a few more conditional checks.

    Cheers,
    Neil

    <xsl:variable name="docs" select="$currentPage/data[@alias='documentList']"/>
    <xsl:if test="$docs != ''">
       <xsl:variable name="splitDocs" select="umbraco.library:Split($docs, ',')" />
       <ul>
          <xsl:for-each select="$splitDocs/value">
        <xsl:if test=". != ''">
           <xsl:variable name="mediaNode" select="umbraco.library:GetMedia(.,0)"/>
           <xsl:if test="$mediaNode != ''">
              <li>
                 <a href="{$mediaNode/data [@alias='umbracoFile']}">
                    <xsl:value-of select="$mediaNode/@nodeName"/>
                 </a>
                  </li>
           </xsl:if>
            </xsl:if>
          </xsl:for-each>
       </ul>
    </xsl:if>
  • David F. Hill 122 posts 242 karma points
    Apr 01, 2010 @ 06:09
    David F. Hill
    0

    Hi Neil,

    Thanks for the code - you rock!

    It worked flawlessly without modification. I just pasted your code and it does exactly what I need.

    I really like how you're testing as you go to make sure there's data.

    Thanks so much!

    David

  • Neil Campbell 58 posts 182 karma points
    Apr 01, 2010 @ 06:22
    Neil Campbell
    0

    No worries David. Glad I could help!
    Yep I always check for data :) I free coded it in notepad, so good to know it runs without mods (for anyone else who stumbles across this post).

    Cheers,
    Neil

     

Please Sign in or register to post replies

Write your reply to:

Draft