Copied to clipboard

Flag this post as spam?

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


  • Winnie 7 posts 97 karma points
    Feb 28, 2023 @ 13:02
    Winnie
    0

    Image carousel - Block List - Umbraco 11

    I'm trying to make an image carousel (slick slider) with the Block List, but when I make the Partial View for the Element Type, the BlockListItem throws errors like "no definition for Media", so I can't get it to render the images the way it's done in the documentation and on the forum.

    What I want for the carousel is client logos with links to the clients' sites and optionally an alt text.

    This is how the Element Type is set up. No settings:

    And this my Partial View code right now, which works:

    Any ideas?

    By the way, I have only worked with Umbraco once before several years ago, so very new to this. I'm used to working in Wordpress.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Feb 28, 2023 @ 14:37
    Huw Reddick
    0

    Hi Winnie,

    try changing your inherits line to

    UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockListItem<ContentModels.ImageCarousel>>
    
  • Winnie 7 posts 97 karma points
    Mar 01, 2023 @ 09:25
    Winnie
    0

    It doesn't work. It gives this error:

    enter image description here

    This is my code:

            @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockListItem<ContentModels.ImageCarousel>>;
        @using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
        @using Umbraco.Cms.Core.Models;
    
    @{
        var content = (ContentModels.ImageCarousel)Model.Content;
    }
    
    <div class="logo-item">
    
        <a href="@content.CarouselImageLink" target="_blank">
        @{
        var typedMediaPickerSingle = Model.Media;
        if (typedMediaPickerSingle is MediaWithCrops mediaEntry)
        {
            <img src="@mediaEntry.MediaUrl()" alt="@content.CarouselImageAltText">
        }
    }        
    </a>
    </div>
    
  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Mar 01, 2023 @ 09:48
    Huw Reddick
    100

    shouldn't Model.Media be content.CarouselImage? (that is your media picker)

  • Winnie 7 posts 97 karma points
    Mar 06, 2023 @ 07:36
    Winnie
    0

    Great, Thank you! It works perfectly.

Please Sign in or register to post replies

Write your reply to:

Draft