Copied to clipboard

Flag this post as spam?

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


  • Tom Bruce 122 posts 506 karma points
    Apr 05, 2018 @ 09:24
    Tom Bruce
    0

    Create a hyperlink to a pdf document

    Hi everyone, I need to create a hyperlink to a pdf document within a partial view.

    I have uploaded the pdf to the Umbraco Media folder, what is the syntax to find the pdf and link it to the hyperlink?

    Any help or pointers much appreciated.

    Code so far

    <a href="PrivacyCookiePolicy.pdf" class="Underlined">Privacy and cookie policy</a>
    

    Thanks in advance. Tom

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 05, 2018 @ 09:39
    Michaël Vanbrabandt
    100

    Hi Tom Bruce,

    you some possibilities:

    1. The url will always be the same

    If this is the case you can go to the Media section and locate your pdf media item. Then on the properties / info tab you will find the Link to media which is something like /media/1089/privacycookiepolicy.pdf.

    Then you can copy the url and paste it into your partial view.

    1. Make it dynamic

    This requires some more setup. A possible solution could be to add a property to your Home root node called Privacy Policy which is of type Media Picker. Then in the Home node you can select the prefered policy media item ( your pdf file ).

    Then in your partial view you can lookup this property recursively:

     var privacypolicy = Model.Content.GetPropertyValue<IPublishedContent>("privacyPolicyAlias", true);
    

    https://our.umbraco.org/documentation/Getting-Started/Backoffice/Property-Editors/Built-in-Property-Editors/Media-Picker2

    Hope this helps.

    /Michaël

  • Tom Bruce 122 posts 506 karma points
    Apr 05, 2018 @ 09:39
    Tom Bruce
    0

    I have managed to link to the pdf, see code below.

    My next question is, is this the best way?

     <a href="~/media/1008/tf13-data-protection.pdf" class="Underlined" target="_blank">Data protection policy</a>
    
Please Sign in or register to post replies

Write your reply to:

Draft