Copied to clipboard

Flag this post as spam?

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


  • nadine 25 posts 75 karma points
    Jun 14, 2013 @ 08:10
    nadine
    0

    Simple retrieval of media files based on custom property

    I am fairly new to XSLT and have been scouring the Forum for ages to my apologies that this is so simple.I have a set of files in my media area contained in a folder structure like this:Forms > Uniforms > winter.pdfForms > Uniforms > summer.pdfForms > Canteen > pricelist.pdfetcI have given them a True / False property called quickForm as I want to display the ones selected as a "hotlist" on my home page.<pre><xsl:param name="currentPage"/> <xsl:template match="/">  <ul>        <xsl:if test="./data [@alias = 'pdfFile'] != ''">    <a href="{umbraco.library:GetMedia(./data [@alias = 'quickForm'],'false')/data [@alias = 'umbracoFile']}">Download PDF</a>   </xsl:if>  </ul>  </xsl:template></pre>This is my current version of the code.Any help would be most appreciated

  • nadine 25 posts 75 karma points
    Jun 14, 2013 @ 08:17
    nadine
    0

    Sorry  hope this turns out better formatted...


    <xsl:param name="currentPage"/>


    <xsl:template match="/">
      <ul>
            <xsl:if test="./data [@alias = 'pdfFile'] != ''">
        <a href="{umbraco.library:GetMedia(./data [@alias = 'quickForm'],'false')/data [@alias = 'umbracoFile']}"><xsl:value-of select="@nodeName"/></a>
       </xsl:if>
      </ul>
      </xsl:template>

  • nadine 25 posts 75 karma points
    Jun 17, 2013 @ 04:40
    nadine
    0

    Ok so the above code didn't work but has anyone got any ideas???

    I just need to access my media property true / false and display those that are true - currently not displaying anything.

     

     I've been trawling the forum and I think I'm getting close.....

    <xsl:variable name="quickForm" select="$currentPage/data [@alias='quickForm']"/>
    <xsl:template match="/">

    <!-- The fun starts here -->
     <xsl:if test="$quickForm">
     <ul>
       <xsl:for-each select="umbraco.library:GetMedia($currentPage/data [@alias='quickForm'], 'true')">
        <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
         <xsl:value-of select="@nodeName"/>
        </a>
       </li>
      
      </xsl:for-each>
     </ul>
     </xsl:if>
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 17, 2013 @ 08:16
    Dennis Aaen
    0

    Hi nadine,

    Reason why you can not get it to work is that you are using a version of Umbraco that is using the new XML schema. The new schema was introduced from version 4.5,

    Looking forward to hear which version you are using. After that maybe I can help you to get your xslt right.

    /Dennis

  • nadine 25 posts 75 karma points
    Jun 17, 2013 @ 10:06
    nadine
    0

    Thanks so much for posting Dennis

    I've started to realise that it's rather confusing as there's not many examples out there with the new schema!

    I have got this to display the files in my forms folder only after specifying the folder id, I still haven't got it to display the files in subfolders with my quickForm (True/False) property. Are you able to help me with that Dennis?

    Nadine

    <xsl:variable name="documents" select="umbraco.library:GetMedia(1113, 1)"/>
        <xsl:template match="/">
            <xsl:if test="count($documents) > 0">
              <ul>
                <xsl:for-each select="$documents/*">
                  <xsl:if test="./umbracoFile != ''">
                  <li><a href="{./umbracoFile}" target="_blank"><xsl:value-of select="./@nodeName" /></a></li>
                  </xsl:if>
                  </xsl:for-each>
              </ul>
            </xsl:if>
        </xsl:template>

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 17, 2013 @ 10:26
    Dennis Aaen
    0

    Hi nadine,

    If I remember correctly, I think something like this should work for you.

    <xsl:variable name="documents" select="umbraco.library:GetMedia(1113, 1)"/>

        <xsl:template match="/">
            <xsl:if test="count($documents) > 0">
              <ul>
                <xsl:if test="$currentPage/quickForm = '1'">
            <xsl:for-each select="$documents//*">
                  <xsl:if test="./umbracoFile != ''">
                  <li><a href="{./umbracoFile}" target="_blank"><xsl:value-of select="./@nodeName" /></a></li>
                  </xsl:if>
                  </xsl:for-each>
              </xsl:if>
              </ul>
            </xsl:if>
        </xsl:template>

    The $documents//* should get the subfolders. The descendant axis retrieves all nodes below the node in reference no matter the depth. http://our.umbraco.org/wiki/reference/xslt/xpath-axes-and-their-shortcuts

    I hope this can help you in some way.

    /Dennis

  • nadine 25 posts 75 karma points
    Jun 17, 2013 @ 10:40
    nadine
    0

    Hi Dennis

    This didn't retrieve anything, would it be because we've specified the folderID in the GetMedia function?

    Nadine

  • nadine 25 posts 75 karma points
    Jun 17, 2013 @ 10:47
    nadine
    0

    It seems to fail on this statement

    <xsl:iftest="$currentPage/quickForm = '1'">

     

    This rest of the code retrieved all of the folders at all levels...

    <xsl:variable name="documents" select="umbraco.library:GetMedia(1113, 1)"/>
        <xsl:template match="/">
      <xsl:if test="count($documents) > 0">
              <ul>           
        <xsl:for-each select="$documents//*">
          <xsl:if test="./umbracoFile != ''">
           <li><a href="{./umbracoFile}" target="_blank"><xsl:value-of select="./@nodeName" /></a></li>
          </xsl:if>
                  </xsl:for-each>        
              </ul>
            </xsl:if>
        </xsl:template>
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 17, 2013 @ 11:16
    Dennis Aaen
    100

    Hi nadine,

    Can´t rember if it´s possible to do it like this.

    <xsl:variablename="documents"select="umbraco.library:GetMedia(1113, 1)"/>

       
    <xsl:templatematch="/">
           
    <xsl:iftest="count($documents) > 0">
             
    <ul>
           
    <xsl:for-eachselect="$documents//*[quickForm = '1']">
                 
    <xsl:iftest="./umbracoFile != ''">
                 
    <li><ahref="{./umbracoFile}"target="_blank"><xsl:value-ofselect="./@nodeName"/></a></li>
                 
    </xsl:if>
                 
    </xsl:for-each>
             
    </ul>
           
    </xsl:if>
       
    </xsl:template>

    But I hope this will work for you.

    /Dennis

  • nadine 25 posts 75 karma points
    Jun 17, 2013 @ 13:05
    nadine
    0

    Dennis you are an absolute star - it works a treat - I had tried variations of that but couldn't get that syntax right!

    Thank you so much!

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 17, 2013 @ 13:39
    Dennis Aaen
    0

    nadine, glad that I could help you out.

    And I´m sure if you have other questions about Umbraco, people in this forum will be happy to help you.

    /Dennis

  • 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