rasmusjp / umbraco-multi-url-picker

Multi Url Picker for Umbraco 7
MIT License
31 stars 29 forks source link

in 7.6 how do i use this with nested content? #61

Closed rbaty-barr closed 6 years ago

rbaty-barr commented 7 years ago

i am close, but not really experienced with Models Builder, can you provide me a bit more of a full example with nested content in mind?

bjarnef commented 7 years ago

I have just used the multi url picker inside Nested Content for columns in footer with a heading + links. https://twitter.com/bfyrstenborg/status/926356380285652994

image

@{
     var footerLinks = site.FooterLinks ?? Enumerable.Empty<IPublishedContent>();

    <div class="row">
        @foreach (var item in footerLinks)
        {
            var links = item.GetPropertyValue<IEnumerable<Link>>("links");

            <div class="col-sm-4 col-md-4">
                <h3>@item.GetPropertyValue("heading")</h3>
                @if (links != null && links.Any())
                {
                    <ul class="list-unstyled links">
                        @foreach (var link in links)
                        {
                            <li><a href="@link.Url" title="@link.Name" target="@link.Target">@link.Name</a></li>
                        }
                    </ul>
                }
            </div>
        }
    </div>
}

or if you only use one document type in nested content.

@{
     var footerLinks = site.FooterLinks ?? Enumerable.Empty<IPublishedContent>();

    <div class="row">
        @foreach (var item in footerLinks.OfType<NestedLinks>())
        {
            <div class="col-sm-4 col-md-4">
                <h3>@item.Heading</h3>
                @if (item.Links != null && item.Links.Any())
                {
                    <ul class="list-unstyled links">
                        @foreach (var link in item.Links)
                        {
                            <li><a href="@link.Url" title="@link.Name" target="@link.Target">@link.Name</a></li>
                        }
                    </ul>
                }
            </div>
        }
    </div>
}
rasmusjp commented 6 years ago

Guess you've figured it out, so closing