Copied to clipboard

Flag this post as spam?

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


  • Fredrik 7 posts 27 karma points
    Jun 15, 2015 @ 11:51
    Fredrik
    0

    Importing Layerslider

    Hi,

    I want to add a slider to my site. Which I have absolutely no idea how to code. Is it possible to create a slider using for example Layerslider in Wordpress and then copying the code and pasting in my Umbraco page? I tried to do it locally but it didn't seem to work. Any idea what may have caused the error?

    Or is there another easier way to do it?

    Thanks!

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 15, 2015 @ 19:44
    Dennis Aaen
    0

    Hi Fredrik,

    An easy way to create an image slider in Umbraco, by to add a media picker to the document type where your clients needs to be able to create a slider.

    In the media picker your client just need to choose the folder, with the images, and then you will create the slider on the page. You can use the Razor code below to loop through the images in the folder. The Razor file can be a partial view or a partial view macro file. You can use this code in both type of files.

    @if(CurrentPage.HasValue("mediaPickerAlias"))
    {
        var media = Umbraco.Media(CurrentPage.mediaPickerAlias);
        var selection = media.Children("Image");
    
        if (selection.Any())
        {
            <ul>
                @foreach (var item in selection)
                {
                    <li>
                        <img src="@item.umbracoFile" alt="@item.Name" />
                    </li>
                }
            </ul>
        }
    }
    

    For the framework to the slider I think that you should take a look at the slick slider. You can find it here http://kenwheeler.github.io/slick/. This framework is also responsive.

    You can find the documentation about how you should structure your HTML by clicking the usage link.

    Remember to change the mediaPickerAlias so it match your alias of the media picker on the document type.

    Hope this helps,

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft