Copied to clipboard

Flag this post as spam?

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


  • Martin 248 posts 587 karma points
    Oct 12, 2017 @ 10:42
    Martin
    0

    Media Picker 2 - Umbraco 7.7 - 'System.Array' does not contain a definition for 'Url'

    Hi All,

    I'm having an issue showing an icon on the multi level navigation.

    I have a property on the document type - "navigationIcon" - which uses the Media Picker 2. I had it working previously on Media Picker 1 with the following code. I understand that Media Picker 2 using the UDI, but Im struggling to get it to work recursively.

    The error message I get is - 'System.Array' does not contain a definition for 'Url'

    Any help would be appreciated.

    Thanks

    Martin

    @foreach (var level2 in childPage.Children.Where("Visible")) {
    <li>
            <a class="cd-nav-item" href="@level2.Url" style="background-image:url('@level2.navigationIcon.Url')">
                <div class="title">@level2.Name</div>
            </a>
    </li>
                            }
    
  • Alex Skrypnyk 3990 posts 14125 karma points mvp
    Oct 12, 2017 @ 11:33
    Alex Skrypnyk
    0

    Hi Martin

    It looks like on your media picker enabled multiple medias, please check, just turn off multiple choice.

    If you need the possibility to select multiple media, try to use this code:

    @foreach (var level2 in childPage.Children.Where(x => x.IsVisible()))
    {
        var imagesList = level2.GetPropertyValue<IEnumerable<IPublishedContent>>("navigationIcon");
        <li>
            <a class="cd-nav-item" href="@level2.Url" style="background-image:url('@imagesList.FirstOrDefault().Url')">
                <div class="title">@level2.Name</div>
            </a>
        </li>
    }
    

    Read more - https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Media-Picker2

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft