Copied to clipboard

Flag this post as spam?

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


  • Fahad Ayub 71 posts 238 karma points
    Dec 19, 2017 @ 15:01
    Fahad Ayub
    0

    Hi, I am struggling to get the the banner/slide show working on my web site main page.

    I googled it and try few thing but still no success. In my back end I would like to give user option to add images in folder. Then all these images should appear as banner/slide show on my man page. I follow this link , still no luck

    I get error :

    Error loading Partial View script (file ....)

    The macro I created by following the above link , shows error in visual studio like

    Library.MediaById doesn not exist in current context. Parameter does not exist

    Any help. Thanks

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 19, 2017 @ 18:32
    Dennis Aaen
    0

    Hi Fahad,

    Can you please let us know what version of Umbraco that you are using and what does your code look like that you have so far.

    If you can share this, then I think some people will be ready to help you out.

    All the best,

    /Dennis

  • Fahad Ayub 71 posts 238 karma points
    Dec 20, 2017 @ 12:03
    Fahad Ayub
    0

    Hi Dennis, I am using Umbraco 7 , and I followed the instructions:

    From you

    Thanks

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 20, 2017 @ 18:41
    Dennis Aaen
    100

    Hi Fahad,

    Perhaps you can use the code snippet that we call Gallery. It looks like this

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @*
        Macro to display a gallery of images from the Media section.
        Works with either a 'Single Media Picker' or a 'Multiple Media Picker' macro parameter (see below).
    
        How it works:
            - Confirm the macro parameter has been passed in with a value
            - Loop through all the media Ids passed in (might be a single item, might be many)
            - Display any individual images, as well as any folders of images
    
        Macro Parameters To Create, for this macro to work:
        Alias:mediaIds     Name:Select folders and/or images    Type: Multiple Media Picker
                                                                Type: (note: You can use a Single Media Picker if that's more appropriate to your needs)
    *@
    
    @{ var mediaIds = Model.MacroParameters["mediaIds"] as string; }
    
    @if (mediaIds != null)
    {
        <div class="row">
            @foreach (var mediaId in mediaIds.Split(','))
            {
                var media = Umbraco.TypedMedia(mediaId);
    
                @* a single image *@
                if (media.DocumentTypeAlias == "Image")
                {
                    @Render(media as Image);
                }
    
                @* a folder with images under it *@
                foreach (var image in media.Children<Image>())
                {
                    @Render(image);
                }
            }
        </div>
    }
    
    @helper Render(Image item)
    {
        <div class="col-xs-6 col-md-3">
            <a href="@item.Url" class="thumbnail">
                <img src="@item.GetCropUrl(width:200, height:200)" alt="@item.Name" />
            </a>
        </div>
    }
    

    Hope this can help you.

    Best, -Dennis

  • Fahad Ayub 71 posts 238 karma points
    Dec 22, 2017 @ 09:30
    Fahad Ayub
    0

    Thanks so much.

Please Sign in or register to post replies

Write your reply to:

Draft