Copied to clipboard

Flag this post as spam?

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


  • Phillip Turner 98 posts 412 karma points
    May 07, 2014 @ 21:29
    Phillip Turner
    0

    uComponents Multi-Url Picker issues v6.1.6 - Partial View

    So all I am trying to get is the Urls from my picker.

    This is the code I am using, but I get an error.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        var page = Umbraco.Content(2055);
    }
    <div id="footer" role="contentinfo">
    <div id="colophon">
        <div id="footer_nav">
            <ul>
            @{foreach (var link in page.footLinks)
                {
                <li><a href="@link.url" @Html.Raw(link.newwindow == "True" ? "target=\"_blank\"" : "")>@link.linktitle</a></li>
                }
            }
            </ul>
        </div>
        @page.footNote
    </div>
    </div>
    

    This is the error I get:

    Cannot implicitly convert type 'uComponents.DataTypes.MultiUrlPicker.Dto.MultiUrlPickerState' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?)
    

    Any ideas?

  • Phillip Turner 98 posts 412 karma points
    May 07, 2014 @ 21:40
    Phillip Turner
    0

    Update...

    so I updated my foreach as such:

    @{foreach (var link in page.UrlPicker.footLinks)
    

    Error now goes away but urls are not iterated.

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    May 07, 2014 @ 21:46
    Jeavon Leopold
    0

    Hi Philip,

    Try this:

    @{
        foreach (var link in page.footLinks.Items)
        {
            var urlPickerLinkTarget = (link.NewWindow) ? "_blank" : null;
            <li><a href="@link.Url" class="@urlPickerLinkTarget">@link.Title</a></li>
        }
    }
    

    Jeavon

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    May 07, 2014 @ 21:59
    Jeavon Leopold
    100

    Oops, little mistake, should be:

    @{
        foreach (var link in page.footLinks.Items)
        {
            var urlPickerLinkTarget = (link.NewWindow) ? "_blank" : null;
            <li><a href="@link.Url" target="@urlPickerLinkTarget">@link.Title</a></li>
        }
    }
    
  • Phillip Turner 98 posts 412 karma points
    May 08, 2014 @ 01:30
    Phillip Turner
    1

    Could not find documentation that stated .Items for iterating, but worked flawlessly!

    As always Mr. Leopold, you are a gentleman and a scholar!

Please Sign in or register to post replies

Write your reply to:

Draft