Copied to clipboard

Flag this post as spam?

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


  • Sam 63 posts 126 karma points
    Apr 20, 2012 @ 08:15
    Sam
    0

    Display containing folder Name of items find in media sections

    Hi ,

    In media sections i have some pdfs listed in folders like this:

    Financial Informations
      - Finance
          - pdf 1
         - pdf 2
      - Annual Reports
         - pdf 1
         - pdf 2

    For now am already listing the pdfs using a media picker and some xslt. But I want also to display the sub folder name for e.g If am listing pdf1. pdf 2 from folder finance ....display this folder name in the front end

    Finance
    pdf 1
    pdf 2

     

    etc..

    Any help.

     

    <xsl:variable name="mediaDoc" select="/macro/pdfFiles"/>

    <xsl:template match="/">

     <xsl:if test="$mediaDoc">
      <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($mediaDoc/*/@id, true())"/>
       

           Problem here : am only able to display top contianing folder with that commented code below:
        <!--<xsl:value-of select="umbraco.library:GetMedia($mediaItems/@parentID, 1)/@nodeName"/>-->
      <div class="docCn"
      <div id="docMnu">
          <ul>
       
      <xsl:for-each select="$mediaItems/Pdf">
          <xsl:sort select="@nodeName" order="ascending" />
        <xsl:variable name="size" select="./umbracoBytes" />
    <xsl:variable name="sizeAndSuffix">
            <xsl:choose>
                    <xsl:when test="$size &gt;= 1073741824">
                            <xsl:value-of select="format-number($size div 1073741824,'#,###')"/>
                            <xsl:textGB</xsl:text>
                    </xsl:when>
                    <xsl:when test="$size &gt;= 1048576">
                            <xsl:value-of select="format-number($size div 1048576,'#,###')"/>
                            <xsl:textMB</xsl:text>
                    </xsl:when>
                    <xsl:when test="$size &gt;= 1024">
                            <xsl:value-of select="format-number($size div 1024,'#,###')"/>
                            <xsl:textKB</xsl:text>
                    </xsl:when>
                    <xsl:when test="$size &gt; 0 and $size &lt; 1024">
                            <xsl:value-of select="format-number($size div 0,'#,###')"/>
                            <xsl:textBytes</xsl:text>
                    </xsl:when>
                    <xsl:otherwise>
                            <xsl:text>0 Bytes</xsl:text>
                    </xsl:otherwise>
            </xsl:choose>
    </xsl:variable>  
        

        <li>
          <href="{umbracoFile}" target='_blank'>
          <xsl:value-of select="@nodeName"/>
            
            <span class="sizedoc">&nbsp;&nbsp;{<xsl:value-of select="$sizeAndSuffix"/>}</span>  
          </a>
          
      </li>
      </xsl:for-each>
     </ul>
        </div>
      </div>
    </xsl:if>

    </xsl:template>

    Thks

     

    //Sam

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Apr 20, 2012 @ 09:04
    Dennis Aaen
    0

    Hi Sam,

    Maybe this post can give you some inspiration to find a solution.

    http://our.umbraco.org/forum/developers/xslt/30685-Display-Folder-Name-and-Its-Sub-Folders-from-Media-Section

    /Dennis

  • Sam 63 posts 126 karma points
    Apr 20, 2012 @ 09:22
    Sam
    1

    Ok solved it. my mistake i was searching for parent Id when i only needed node id

    Replaced that:

     <xsl:value-of select="umbraco.library:GetMedia($mediaItems/@parentID, 1)/@nodeName"/>

    with that:

     <xsl:value-of select="umbraco.library:GetMedia($mediaItems/@id, 1)/@nodeName"/>

Please Sign in or register to post replies

Write your reply to:

Draft