Copied to clipboard

Flag this post as spam?

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


  • Ruben Verhaaf 4 posts 34 karma points
    Sep 14, 2014 @ 22:44
    Ruben Verhaaf
    0

    How to pass a media item to an Umbraco page?

    In my site I have created a media type for audio files with underlying downloads (PDF files for lecture notes). I am able to list the files on a page and make them downloadable. However, I would like to create a page for each audio file on which more information is displayed for the file, and a neat list of all the associated lecture note files is displayed. 

    Is there a way to create a page in Umbraco (or a custom page) to which I pass the media item (in this case the audio file-media item) as a parameter, which looks up the actual media item and lists all the associated lecture note PDFs?

    Some help would be greatly appreciated!

  • Tobias Klika 101 posts 570 karma points c-trib
    Sep 15, 2014 @ 08:47
    Tobias Klika
    100

    What if you just append a query string to your URL? (like .../?media=1035) Then you can create a controller for your DocumentType and check the Request property if it contains the media query.

    What you can also do is implement the IContentFinder which can redirect to a specific controller for specific URLs.

    Bye Tobi

  • Ruben Verhaaf 4 posts 34 karma points
    Feb 07, 2015 @ 11:59
    Ruben Verhaaf
    0

    Thanks :), that works fine. 

    I now use a link to a page, containing a query string parameter like this: <a href="/audio-file?mediaId=@mediaItem.Id">go</a>.

    Then I get the right media item in my template (or in a helper class to separate code from html): 

    var mediaId = HttpContext.Current.Request.QueryString["mediaId" ];
    var mediaItem = Umbraco.TypedMedia(mediaId);
Please Sign in or register to post replies

Write your reply to:

Draft