I used to used the RJP.MultiUrlPicker for creating my navigations. Now that there is a default MultiURLPicker in Umbraco all of my code from previous projects does not work. (Thanks Umbraco update :).
I used to iterate through the RJP.MultiUrlPicker items and could determine if an item was a parent item via the item.Id. The item.Id does not seem to be an option. What other options are available for the new MultiURLPicker that I could use to identify the document type for one of the items?
The new Link class for the core Multi URL Picker has a Udi property for each link.
You can use this to query for the content node, e.g.
var nodeOfLink = Umbraco.TypedContent(item.Udi);
You may want to be careful though as links can also be external and not based on a content node, so this code would throw an exception in that case as the Udi would be null / empty, e.g.
System.InvalidOperationException: UDIs for content items must be Umbraco.Core.GuidUdi
As such you could test the Type property of the link is "Content" to make sure it's a content node first. You could also verify the value of the Udi is a valid GuidUdi object and not null.
Multi URL Picker item Id
I used to used the RJP.MultiUrlPicker for creating my navigations. Now that there is a default MultiURLPicker in Umbraco all of my code from previous projects does not work. (Thanks Umbraco update :).
I used to iterate through the RJP.MultiUrlPicker items and could determine if an item was a parent item via the item.Id. The item.Id does not seem to be an option. What other options are available for the new MultiURLPicker that I could use to identify the document type for one of the items?
Anyone???
Hi
MultiUrls is deprecated.
Instead cast the value IEnumerable or Link if you have set maximum = 1 in the property editor config. Change your code to:
Thanks,
Alex
I have done this, but there is not an attribute for item.id. I need to determine the document type of the item like I did before.
The new Link class for the core Multi URL Picker has a Udi property for each link.
You can use this to query for the content node, e.g.
You may want to be careful though as links can also be external and not based on a content node, so this code would throw an exception in that case as the Udi would be null / empty, e.g.
As such you could test the Type property of the link is "Content" to make sure it's a content node first. You could also verify the value of the Udi is a valid GuidUdi object and not null.
Hope this helps!
Chris
Thanks Chris, that worked!
is working on a reply...