Copied to clipboard

Flag this post as spam?

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


  • blackhawk 313 posts 1368 karma points
    Mar 24, 2017 @ 19:52
    blackhawk
    0

    Renaming a document that is attached to multiple pages

    I may have a writer who needs to link a single PDF onto multiple pages (content nodes). Can we link that PDF in such a way, that if the writer ever needs to rename the PDF, the name also changes on all pages that have the PDF linked? Is this possible through Umbraco?

  • Marc Goodson 2157 posts 14434 karma points MVP 9x c-trib
    Mar 24, 2017 @ 20:07
    Marc Goodson
    1

    Hi Kensley

    You've probably noticed if you make an anchor link, and choose 'link to file' and pick the pdf from the media section of Umbraco, then what is embedded inside the rich text area is

    <a href="/media/1234/somename.pdf">My Pdf</a>
    

    If the editor then replaces somename.pdf with somename2.pdf in the media section, that these links are NOT automatically updated.

    They would need to be 're-inserted' into each rich text area to update the link.

    If this is a common scenario, then a workaround is to create a new Macro, called InsertPDFLink, let it have a parameter of media picker type, and implement a macro partial view, to take the id of the picked media, and retrieve the PDF from the media section, writing out it's Url, if the file ever changes in the future, with this method, the Ids remain the same, and the updated Url is written out for the new file. You also have control over the markup being writted out, and so can put an

    <i class="icon icon-document"></i> 
    

    in front of the link to indicate type.

    enter image description here

    enter image description here

    and your macro partial would be something like this:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @{ var mediaId = Model.MacroParameters["PdfFile"]; }
    @if (mediaId != null)
    {
        @* Get all the media item associated with the id passed in *@
        var mediaItem = Umbraco.TypedMedia(mediaId);
    
    
        if (mediaItem!=null)
        {
     <p><i class="icon icon-document"></i><a href="@mediaItem.Url">@mediaItem.Name</a></p>
                }
    
    }
    

    and the editor would see

    enter image description here

    regards

    Marc

  • blackhawk 313 posts 1368 karma points
    Mar 24, 2017 @ 20:51
    blackhawk
    100

    Thank you so much marc! I will play with this process shortly on my end and get back to you.

  • Marc Goodson 2157 posts 14434 karma points MVP 9x c-trib
    Mar 24, 2017 @ 21:05
    Marc Goodson
    1

    cool,

    Editors also tend to appreciate this package:

    https://our.umbraco.org/projects/backoffice-extensions/media-content-usage/

    it tracks where a media item has been used!

  • blackhawk 313 posts 1368 karma points
    Mar 27, 2017 @ 22:29
    blackhawk
    0

    Thanks again marc, I got both solutions working for me. Much appreciated.

  • 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.

    Continue discussion

Please Sign in or register to post replies