Copied to clipboard

Flag this post as spam?

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


  • Jess Bonde 25 posts 55 karma points
    Sep 22, 2011 @ 09:40
    Jess Bonde
    0

    Only show if file is uploaded

    I've added an upload property to my document type and display the file with

    <umbraco:Item field="myFile" runat="server"></umbraco:Item>

    Simple simple, now how do I ask if the file is uploaded and only display it if it's there?
    /J

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Sep 22, 2011 @ 11:37
    Lee Kelleher
    0

    Hi Jess,

    If the property for "myFile" has an uploaded file, then the <umbraco:Item> tag that you've put in your template will display the value/filepath ... otherwise it displays nothing.

    If you needed to make the filepath into a link, then you could try this?

    <umbraco:Item runat="server" Field="myFile" insertTextBefore="&lt;a href=&quot;" insertTextAfter="&quot;&gt;Download file&lt;/a&gt;" />

    Note: The HTML in the before/after attributes is escaped.  Replace the "Download file" text with whatever you prefer.

    Cheers, Lee.

  • Jess Bonde 25 posts 55 karma points
    Sep 22, 2011 @ 11:50
    Jess Bonde
    0

    Great! Thank you.

  • Mr A 216 posts 278 karma points
    Sep 22, 2011 @ 17:16
    Mr A
    0

    @Lee , can we use something like this:

    <a href="@Model.myfile"/>
  • 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