Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 936 posts 2571 karma points
    Oct 27, 2010 @ 09:41
    Claushingebjerg
    0

    link to media file from menu

    I have a site set up, where i need to have one of menu items link to a file in the media section.

    What i have done is creat a document type called "PDF link". On this document type i have a media picker.

    So i thought giving this media picker the alias "umbracoRedirect" would do the trick, but i was wrong. umbracoRedirect apparently only works with content...

    How do i get this to work in the simplest possible way, preferbly without .net code?

     

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Oct 27, 2010 @ 10:40
    Lee Kelleher
    1

    Hi Claushingebjerg,

    Nice try with the "umbracoRedirect" alias - I like your thinking!  But as you found out it wouldn't work.

    The problem is that with a media-type, you have to know its property aliases too.  The only way I can see this working is by using XSLT to build the menu/nav links.

    You can test if the media-picker has a value, then call GetMedia and render out the "umbracoFile" path instead of calling "NiceUrl".

    Cheers, Lee.

  • Claushingebjerg 936 posts 2571 karma points
    Oct 27, 2010 @ 10:58
    Claushingebjerg
    2

    Cool. Thanks for the pointer...

    I did it this way

    <xsl:choose>
    <xsl:when test="pdffile !=''">
      <a href="{umbraco.library:GetMedia(pdffile, false())/umbracoFile}" target="_blank">
      <xsl:value-of select="@nodeName"/></a>
    </xsl:when>
    <xsl:otherwise>
        <a href="{umbraco.library:NiceUrl(@id)}">
        <xsl:value-of select="@nodeName"/></a>
      </xsl:otherwise>
    </xsl:choose>
  • Tv 2 posts 22 karma points
    Jun 18, 2011 @ 11:00
    Tv
    0

    Great, just what i needed :) Thx for the code!

  • Bent Holz 100 posts 273 karma points
    Nov 17, 2013 @ 13:26
    Bent Holz
    0

    Yeah thx... works like a charm

Please Sign in or register to post replies

Write your reply to:

Draft