Copied to clipboard

Flag this post as spam?

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


  • Alex 4 posts 74 karma points
    Jul 07, 2022 @ 15:30
    Alex
    0

    Umbraco Carousel

    Hello, I am new to Umbraco (cloud) and I am trying to create a carousel slider in my website.

    I created a document type called Slider Image which contains a single Image Media Picker property (alias:innerImage).

    Slider Image

    In Content I created three Slider Image Items under Homepage (all have uploaded images).

    Slider Image Item

    I created a Partial View called Main Slider where I put the Razor and HTML markup

    Main Slider

    Finally I inserted the Partial View into my Homepage template (line 83).

    Homepage

    My problem is that I cannot access the innerImage url. I can access the Slider Image Item's name and url but not its property. Any insight would be welcome.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Jul 11, 2022 @ 12:36
    Huw Reddick
    0

    you are using item.Url() which is the url of the slider Image node.

    you need to get the InnerImage property of Slider Image, so try something like this to get the inner image

    @foreach(var item in selection){
    var innerImage = item.Value<MediaWithCrops>("innerImage")
    
    }
    
  • Ambert van Unen 175 posts 819 karma points c-trib
    Jul 11, 2022 @ 14:07
    Ambert van Unen
    0

    First thing I can recommend is to add a Mediapicker with 1-3 images in the configuration on the document type you want to put the slider. Else you'll pollute your content tree with nodes that aren't actually pages. (Even better is to use a composition, but that might be a bit farfetched for now ;-))

    So for example on your Blog you'll add a MediaPicker which can select 1-3 images.

    This way you can easily group your content.

    Then on the blog partial view you can loop through each file in the picker (as in Huw's post).

Please Sign in or register to post replies

Write your reply to:

Draft