rasmusjp/umbraco-multi-url-picker

Using Multi Url Picker without Models builder

Opened this issue · 3 comments

Trying to use Multi Url Picker without models builder. Strongly typed, not dynamic. It would be great to include an example of this on the readme page similar to the below. I am assuming that I can test for data with HasValue() per below?

if (searchItem.HasValue("overviewLinks"))
                    {
                        var multiUrlPicker = searchItem.GetPropertyValue<IEnumerable<Link>>("overviewLinks");
                        
                        if (multiUrlPicker.Any() && multiUrlPicker != null)
                        {
                            <ul>
                                @foreach (var item in multiUrlPicker)
                                {
                                    <li><a href="@item.Url" target="@item.Target">@item.Name</a></li>
                                }
                            </ul>
                        }
                    }

Having a quick look at the source I'm not entirely sure that .HasValue() always works, but .GetValue<IEnumerable<Link>>() should always return a collection (if using v1 or if using v2 and the Max number of items pre value is greater than 1) where you can use multiUrlPicker.Any()

If Max number of items is 1 and you are using v2+ you can use .GetPropertyValue<Link>() and do a null check afterwards

Thanks for your quick response. on 7.12.3 looks like HasValue() is working as far as I can tell. Since most property editors offer this as a universal value presence test, it would be great to ensure that that is in there. This picker is sorely missing in the core of Umbraco and desperately needed. Thanks for making this available!

Nice to know it's working. I'm happy to let you know it's going to be a part Umbraco 7.14 (umbraco/Umbraco-CMS@e1c9b18).