Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Victoria 4 posts 74 karma points
    1 week ago
    Victoria
    0

    Rendering custom properties in a template

    Hey there,

    I've created a custom property (addressFinder), with a valueType "JSON", and 3 properties in the JSON object (addressLatitude, addressLongitude, and locationAddress). Here's the package.manifest:

    enter image description here

    I'm using the data type in a document type called 'Office Location' where I'm wanting admin users to enter map locations that I'm going to use for a single Google map on another page.

    I'm trying to render out an array of the location data from addressFinder on another page (a document type called 'Map'), and was just wondering how I access the stored JSON data? I'm actually using a partial view macro file within a page, but I'm assuming it's the same syntax.

    I tried both of the following to no avail (just to see if I could get a value printed out):

    enter image description here enter image description here

    Is anyone able to point me in the right direction in terms of accessing the fields within my JSON object?

    Many thanks,

    Victoria

  • Chris Evans 64 posts 147 karma points c-trib
    1 week ago
    Chris Evans
    0

    You'll probably want to implement a custom property convertor.

    This would handle deserializing the JSON into an object that you can use in your partial view (and anywhere else on the site that might use the same data type).

    There is a good example of how to do that in the following forum post : https://our.umbraco.com/forum/umbraco-7/developing-umbraco-7-packages/61760-A-question-about-property-converters#comment-210057

    Hope that helps!

Please Sign in or register to post replies

Write your reply to:

Draft