Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Multi Url Picker without Models builder #89

Open
jattwood opened this issue Jan 17, 2019 · 3 comments
Open

Using Multi Url Picker without Models builder #89

jattwood opened this issue Jan 17, 2019 · 3 comments

Comments

@jattwood
Copy link

jattwood commented Jan 17, 2019

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>
                        }
                    }
@rasmusjp
Copy link
Owner

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

@jattwood
Copy link
Author

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!

@rasmusjp
Copy link
Owner

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants