Copied to clipboard

Flag this post as spam?

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


  • Henrik 11 posts 61 karma points
    Dec 02, 2020 @ 19:01
    Henrik
    0

    Problem rendering Multi-Url-Picker

    I am trying to render a Multi-Url-Picker using the standard Umbraco documentation at: https://our.umbraco.com/Documentation/Getting-Started/Backoffice/Property-Editors/Built-in-Property-Editors/Multi-Url-Picker/index-vpre8_8

    The datatype "secondaryNav" is placed on a "SiteSettings" page node in the content tree where i have my settings.

    Unfortunately i keep getting this error message. Since i am using code taken directly from the documentation it must be something about my "siteSettings"-setup that causes the problem but i cannot see what.

    enter image description here

    My code:

    @{
        var siteSettings = root.SiblingsAndSelf().Where(x => x.ContentType.Alias == "siteSettings").First();
        var links = siteSettings.Value<IEnumerable<Link>>("secondaryNav");
         if (links.Any())
         {
             foreach (var link in links)
             {
                 <li><a href="@link.Url()" target="@link.Target">@link.Name</a></li>
             }
         }
     }     
    
  • Steve Morgan 1346 posts 4453 karma points c-trib
    Dec 03, 2020 @ 08:08
    Steve Morgan
    100

    Hi,

    link is a special model that has the following:

       public string Name { get; set; }
        public string Target { get; set; }
        public LinkType Type { get; set; }
        public Udi Udi { get; set; }
        public string Url { get; set; }
    

    So as you can see Url is a string here not a method you can call.. so just change

    <li><a href="@link.Url()" target="@link.Target">@link.Name</a></li>
    

    to:

    <li><a href="@link.Url" target="@link.Target">@link.Name</a></li>
    
  • Henrik 11 posts 61 karma points
    Dec 03, 2020 @ 10:36
    Henrik
    0

    Thanks so much. That fixed it.

  • Owain Williams 480 posts 1412 karma points MVP 6x c-trib
    Dec 03, 2020 @ 10:18
    Owain Williams
    1

    This is my mistake - sorry, I updated the documents for this section yesterday and it is indeed incorrect.

    Thanks for highlighting this @Henrik

  • Henrik 11 posts 61 karma points
    Dec 03, 2020 @ 10:30
    Henrik
    0

    No worries :)

Please Sign in or register to post replies

Write your reply to:

Draft