Copied to clipboard

Flag this post as spam?

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


  • Garrett Fisher 341 posts 496 karma points
    Nov 13, 2009 @ 21:27
    Garrett Fisher
    0

    how to get filename from media picker field?

    Hi,

    I have a document type that uses a media picker field called "file".  I chose a PDF in the page instance and saved/published.  In my XSLT, I have a link to it:

    <a href="{./data [@alias = 'file']}" target="_new">PDF</a>

    But, oddly, all this is outputting is a NUMBER (eg. "1453").  Why wouldn't it give me the path to the file??  How can I get this to print in the href?  1453 is meaningless.

    Thanks,

    Garrett

  • Ricky Beard 61 posts 116 karma points
    Nov 14, 2009 @ 02:09
    Ricky Beard
    1

    Try:

    {umbraco.library:NiceUrl(./data [@alias = 'file'])}
  • dandrayne 1138 posts 2262 karma points
    Nov 14, 2009 @ 17:17
    dandrayne
    2

    You probably need getMedia

    {umbraco.library:GetMedia(./data [@alias = 'file'], 'false')/data [@alias = 'umbracoFile']}

    Dan

  • Garrett Fisher 341 posts 496 karma points
    Nov 19, 2009 @ 22:27
    Garrett Fisher
    0

    Actually, GetMedia isn't working but Ricky's code is.... Thanks to you both!  This is the best Forum ever, btw....

    //Garrett

  • Garrett Fisher 341 posts 496 karma points
    Dec 09, 2009 @ 21:22
    Garrett Fisher
    0

    I'm getting inconsisten results when trynig to get filenames from either media picker fields or upload fields.  In this case, I have a doc type which has one property-- DownloaFile-- and all I am trying to do is to insert the filenames into an href tag in a list of links in the XSLT file.  Here is my code:

    <xsl:for-each select="$currentPage/node [@nodeTypeAlias = 'VendorDocument']">
    <li>
    <a href="{umbraco.library:GetMedia(./data [@alias = 'DownloadFile'], 'true')/data [@alias = 'umbracoFile']}">
    <xsl:value-of select="@nodeName"/>
    </a>
    </li>
    </xsl:for-each>

    What's wrong with this?  I'm getting an "Error parsing XSLT file: \xslt\VendorDocumentList.xslt" error.

    Thanks for the continued help.

    //Garrett

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Dec 09, 2009 @ 21:34
    Peter Dijksterhuis
    0

    Try this:

    <xsl:if test="./data [@alias = 'DownloadFile'] != '' ">
       <li>
                    <a href="{umbraco.library:GetMedia(./data [@alias = 'DownloadFile'], 'true')/data [@alias = 'umbracoFile']}">
                            <xsl:value-of select="@nodeName"/>
                    </a>
            </li>
    </xsl:if>

    (ofcourse surrounded with your for-each)

    HTH,

    Peter

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Dec 09, 2009 @ 21:40
    Dirk De Grave
    0

    Me thinks media picker fields and upload fields store their values differently. Media pickers store the id of the media it references while an upload field complete file info on the document node itself.

    For media pickers, you could use the code from your last post, for upload fields, you'd need a slightly different approach (altho don't know by heart which one). I always tend to output the value for the property first, and change the xslt according to the output.

    Output field value of property using:

    <textarea><xsl:copy-of select="./data [@alias = 'DownloadFile']" /></textarea>

     

    Hope this helps.

    Regards,

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft