Copied to clipboard

Flag this post as spam?

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


  • Morten Ørgaard 5 posts 95 karma points
    Mar 02, 2021 @ 21:12
    Morten Ørgaard
    0

    I have previously worked a lot in Umbraco 7, but for the last 4-5 years, I have been working on different Linux environments.

    Currently, I am working on a Umbraco project, which is nice. However, I am a bit rusty.

    I have a document with a Multinode Treepicker, that only allows items of one type: Link.

    The Link document has a mandatory URL Picker with a maximum of 1 item.

    I can loop through the Moltinode Treepicker and write the item properties. But I am struggling to get the URL Picker values from the item.

    Any help will be appreciated.

    Kind regards Morten

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Mar 02, 2021 @ 21:21
    Dennis Aaen
    0

    Hey Morten

    If you are using the Multi URL picker then you can find examples on how to get values from the property editor here

    https://our.umbraco.com/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Multi-Url-Picker/

    Hope this helps

    /Dennis

  • Morten Ørgaard 5 posts 95 karma points
    Mar 02, 2021 @ 21:29
    Morten Ørgaard
    0

    I have been looking into that, but I can't seem to make it work.

    This is what I currently have.

    @{
    var linkNodes = Model.Value<IEnumerable<IPublishedContent>>("linkNodes");
    foreach (var linkNode in linkNodes)
    {
        var link = linkNode.Value<Link>("navLink");
        <a href="#" target="@link.Target">@linkNode.Name</a>
    }
    

    }

    Without the link part I do get the nodes printed.

  • Huw Reddick 1736 posts 6076 karma points MVP c-trib
    Mar 02, 2021 @ 21:45
    Huw Reddick
    0

    I do mine like this

    IEnumerable<Link> centrelinks = (IEnumerable<Link>)siteSection.GetProperty("centreLinks").Value();
    
                    @if (centrelinks != null && centrelinks.Any())
                    {
                        <ul class="list">
                            <li><h3>@centreheading</h3></li>
                            @foreach (Link link in centrelinks)
                            {
                                <li class=""><a href="@link.Url" target="@link.Target">@link.Name</a></li>
                            }
                        </ul>
                    }
    

    Don't know if that helps at all

  • Morten Ørgaard 5 posts 95 karma points
    Mar 02, 2021 @ 22:06
    Morten Ørgaard
    0

    My initial code was like this:

    @{
        IEnumerable<IPublishedContent> linkNodes = Model.Value<IEnumerable<IPublishedContent>>("linkNodes");
        foreach (IPublishedContent linkNode in linkNodes)
        {
            IEnumerable<Link> link = (IEnumerable<Link>)linkNode.Value("navLink");
        }
    }
    

    I have also tried:

    @{
        IEnumerable<IPublishedContent> linkNodes = Model.Value<IEnumerable<IPublishedContent>>("linkNodes");
        foreach (IPublishedContent linkNode in linkNodes)
        {
            Link link = (Link)linkNode.Value("navLink");
        }
    }
    

    Both throws a runtime error.

  • Morten Ørgaard 5 posts 95 karma points
    Mar 02, 2021 @ 22:23
    Morten Ørgaard
    100

    I found my error.

    I am not sure why I didn't customError mode off earlier.

    My document type was also link. Renaming the alias to pageLink my initial code works as expected.

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft