Gibe / Umbraco-Link-Picker

Link picker property editor for Umbraco 7
12 stars 10 forks source link

Using the output #1

Closed sunnefa closed 9 years ago

sunnefa commented 9 years ago

Hi, thanks for a useful package! Maybe I'm just dense but how do I then use the output from the link picker? I know it's in Json format, is there an object that I can deserialize it to or would I need to create that object myself? Right now if I just deserialize to object I only get "object does not have a definition for url" errors. Thanks for any help :-)

karltynan commented 9 years ago

The data that is returned (I will add to the readme) will be "id", "name", "url" and "target".

For dynamic I think you can just use code>@CurrentPage.fieldName.url</code. If you are using strongly typed, or want to deserialize the object, then I suggest using Newtonsoft.Json:

var data = JsonConvert.DeserializeObject(value.ToString());
public class LinkPickerModel
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Url { get; set; }
    public string Target { get; set; }
}

Hope that helps?

sunnefa commented 9 years ago

Thank you! I ended up creating a model class for this. Perhaps it would be a good idea to include that in the next version (if there is another version planned) or add something on the subject to the readme file :-)

karltynan commented 9 years ago

We are planning to release the converter we have created for this to use with Ditto by Lee Kelleher (https://github.com/leekelleher/umbraco-ditto) and bundle a model class for those not using Ditto.