Copied to clipboard

Flag this post as spam?

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


  • Keith R Hubbard 175 posts 403 karma points
    Jan 14, 2016 @ 16:19
    Keith R Hubbard
    0

    Getcrop with IpublishedContent from a MediaFolder with MediaType name banner

    I am trying to get a crop from a strongly typed partial from a mediafolder. the Media type is called banner and i want to utilized slick slider. Below is a screen shot of the MediaType. enter image description here

    and the partial.

        @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    @{
        var mediaFolderId = Umbraco.Media(Model.Content.GetPropertyValue<int>("Banner"));
        }
    
    @if (mediaFolderId > 0)
    {
        var mediaFolder = Umbraco.TypedMedia(mediaFolderId);
        var banners = mediaFolder.Children();
    
        <section class="slider">
            <div class="slider single-item">
                @foreach (var banner in banners)
                {
                    var link = Umbraco.TypedContent(banner.GetPropertyValue<int>
                        ("link"));
    
                    <div class="banner">
                        @if (link != null)
                        {
                            <a href="@link.Url">
                                <img src="@(banner.GetResponsiveCropUrl(" banner"))" />
                            </a>
                        }
                        else
                        {
                            <img src="@(banner.GetResponsiveCropUrl(" banner"))" />
                        }
    
                        <div class="text">
                            <h2>@(banner.GetPropertyValue<string>("headline"))</h2>
                            @Html.Raw(banner.GetPropertyValue("text"))
    
                        </div>
                    </div>
                }
            </div>
        </section>
    }
    

    i hope someone can show me the right way to do this.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jan 14, 2016 @ 18:36
    Jeavon Leopold
    1

    I'm sure of the issue here apart from you have a space in the parameter?

    " banner"

  • Keith R Hubbard 175 posts 403 karma points
    Jan 14, 2016 @ 18:53
    Keith R Hubbard
    0

    @jeavon I changed the space but umbraco does not see the partial. what do you mean sure of the issue? is the code correct for it to skip the partial entirely?

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jan 14, 2016 @ 18:56
    Jeavon Leopold
    0

    Ok, how are you calling the Partial View from the View?

  • Keith R Hubbard 175 posts 403 karma points
    Jan 14, 2016 @ 18:56
    Keith R Hubbard
    0

    here is the updated code

    @{ var mediaFolderId = Umbraco.Media(Model.Content.GetPropertyValue

    @if (mediaFolderId > 0) { var mediaFolder = Umbraco.TypedMedia(mediaFolderId); var banners = mediaFolder.Children();

    <section class="banner-slider">
        <div class="slick-slider single-item">
            @foreach (var banner in banners)
            {
                var link = Umbraco.TypedContent(banner.GetPropertyValue<int>
                    ("link"));
    
                <div class="banner">
                    @if (link != null)
                    {
                        <a href="@link.Url">
                            <img src="@(banner.GetResponsiveCropUrl("banner"))" />
                        </a>
                    }
                    else
                    {
                        <img src="@(banner.GetResponsiveCropUrl("banner"))" />
                    }
    
                    <div class="text">
                        <h2>@(banner.GetPropertyValue<string>("headline"))</h2>
                        @Html.Raw(banner.GetPropertyValue("text"))
    
                    </div>
                </div>
            }
        </div>
    </section>
    

    }

  • Keith R Hubbard 175 posts 403 karma points
    Jan 14, 2016 @ 18:58
    Keith R Hubbard
    0
    @Html.Partial("~/Views/Partials/slick.cshtml")
    

    from the home view for now

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jan 14, 2016 @ 18:59
    Jeavon Leopold
    1

    and nothing appears at all?

  • Keith R Hubbard 175 posts 403 karma points
    Jan 14, 2016 @ 19:03
    Keith R Hubbard
    0

    not a thing. it bypasses the partial.

Please Sign in or register to post replies

Write your reply to:

Draft