Copied to clipboard

Flag this post as spam?

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


  • Benoit Cornette 29 posts 169 karma points
    Nov 08, 2017 @ 22:31
    Benoit Cornette
    0

    Media library

    Hi,

    Does anyone has experience with a media library? It should be a page that renders all the folders and files from the “Media” sectio’s.

    Every directory has a name and files.

    Any ideas?

    Kind regards,

    Benoit

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Nov 08, 2017 @ 23:26
  • Benoit Cornette 29 posts 169 karma points
    Nov 09, 2017 @ 14:14
    Benoit Cornette
    0

    Hi Alex,

    Correct, get's me started but I don't want to show all files and folders immediately. So just the folders at the root, when a visitor clicks on one of the folders you should go to a page (/folder-name) with all the files/folders. How can I generate these pages? When I do "@media.Url", the value is empty...

    Kind regards,

    Benoit

  • Benoit Cornette 29 posts 169 karma points
    Nov 15, 2017 @ 14:30
    Benoit Cornette
    0

    Hi,

    So this is my code at the moment:

    @{
        var listRoot = Umbraco.TypedMedia(1174);
    }
    
    @foreach (var item in listRoot.Children)
    {
        if (item.DocumentTypeAlias == "Folder")
        {
            <li class="image-tile inner-tile hover-reveal text-center">
                <a href="@item.Name" data-lightbox="false">
                    @item.Name                                        
                </a>
            </li>
        }
        else if (item.DocumentTypeAlias == "Image")
        {
            <li>
                <a href="@item.Url" data-lightbox="true">
                    <div class="background-image-holder">
                        <img alt="image" class="background-image" src="@item.Url" />
                    </div>
                </a>
            </li>
        }
    }
    

    This takes care of displaying all the images in the main folder and the folders in the main folder. My question is, how do I get the specific URL for a folder that's in the main folder. With "@item.Url" I get a URL but this gives me a 404. At this page I should display the images in that folder... So a typical gallery with albums.

    Any help? Stuck on this for a week...

    Kind regards,

    Benoit

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Nov 15, 2017 @ 14:59
    Michaël Vanbrabandt
    100

    Hi Benoit,

    The way I think you should go to is using querystrings.

    So when you render your images and folder you can set the folder with a hyperlink where you add a link to the current page but with a querystring which contains the foldername.

    Like for example:

    String.Format("{0}?folder={1}", Model.Content.Url, item.Id)
    

    Where Model.Content.Url is the url of the current page where you load the media library and the item.Id will be the Id of the media folder.

    Make sure to add a check to see if its a folder or not in your foreach statement.

    After that you can collect the folder by using Request.Querystring["folder"], also bear in mind to do some checks in order to load the main folder contents or the contents for the given folder in the url.

    Hope this helps.

    Have a nice day

    /Michaël

  • 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