Copied to clipboard

Flag this post as spam?

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


  • thanhtien501 28 posts 48 karma points
    Nov 17, 2010 @ 07:59
    thanhtien501
    0

    Get list of media in a folder by NodeID

    Hi All

    I created  a folder in media section. after that i upload 3 files into this folder. And i try to get list of 3 file in this folder by the folder Node ID but it did not work.

    My xslt look l

    <xsl:param name="currentPage"/>
    <xsl:param name="ParentNodeID" select="/macro/ParentNodeID"/>
        
    <xsl:template match="/">

    <!-- start writing XSLT -->
    <xsl:if test="$ParentNodeID!=''">

       <table  class='exchOn' id="MoneySaverate" border="0" cellspacing="1">
         <tbody>
           
           <xsl:for-each select="umbraco.library:GetMedia($ParentNodeID, 'true')/*[@isDoc]">
    <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of
    select="@nodeName"/></a>

            </xsl:for-each>       
          </tbody>
       </table>
    </xsl:if>
     

     

    The $ParentNodeId is  the argument of the Macro. it is the node Id of the folder that contains 3 files

    I use umbraco 4.6.0 alpha

      thanh for your patience.

  • John C Scott 473 posts 1183 karma points
    Nov 17, 2010 @ 13:34
    John C Scott
    0

    do you get nothing at all? or just three empty links?

    ie when you view source - or if you add a character (I always add a Z just so I remember I need to take it out) does that repeat 3 times?

    I suspect that the problem is that {umbraco.library:NiceUrl(@id)}and @nodeName do not return anything for a media item

    it's a different library call for a media item id

    i'll check this out if you the above is the case and let you know which is the correct call

    however if it's returning nothing at all then it would be a different problem

     


  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 17, 2010 @ 14:05
    Tom Fulton
    0

    Hi -

    I haven't tested on 4.6, but a few things on 4.5

    - Remove the [@isDoc] from your for-each xpath - Media items don't use this

    - Media Items also don't use NiceUrl as stated above - use href="{umbracoFile}" instead to link directly to the media item

    <xsl:for-each select="umbraco.library:GetMedia($ParentNodeID, true())/*">
               <a href="{umbracoFile}"><xsl:value-of
                        select="@nodeName"/></a>
            </xsl:for-each>
  • thanhtien501 28 posts 48 karma points
    Nov 17, 2010 @ 22:56
    thanhtien501
    0

    Thank you 2 of you

    Dear Tom: it works smoothly. thank you so much, you save my time.

Please Sign in or register to post replies

Write your reply to:

Draft