Using Content Picker Type for Macro Parameter in Umbraco

Umbraco 7.6 introduced the new property editor ContentPicker2 to replace ContentPicker. ContentPicker2 returns IPublishedContent instead of Node ID. When updating old content picker partial view macro parameters to the new content picker type, you will need to make some changes to your partial view

For example, if you have a parameter called Widget that currently uses the original content picker the following would return an integer node id.


But a parameter using the new content picker would return an identifier in UDI format similar to the following.


To convert the UDI string into an IPublishedContent object, it needs to be parsed and then passed into the Umbraco.TypedContent() method as follows.

var widget = Umbraco.TypedContent(Udi.Parse(Model.MacroParameters["widget"].ToString()));