Copied to clipboard

Flag this post as spam?

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


  • James 10 posts 50 karma points
    Mar 19, 2018 @ 00:11
    James
    0

    Display Custom Property in Front End

    Hi all.

    I've been following the 'creating a property editor' tutorial, but I am struggling to understand how to display this on the front end of my website.

    For my example, I have created a custom Quote property. It has Quote and Source inputs. Everything is working and I can see this in the back office.

    To render this on the website I was hoping I could just use @Umbraco.Field("quote") but unfortunately this renders { "quote": "hello world", "source": "source" }

    I can't see how this should be done in the documentation. Am I missing something simple?

    I could intercept it with a controller and build up my own view model and return a partial, which should be easy enough to do. I am just not sure what is actually correct.

    If anyone can help, or link to a simple blog post that would be great!

    Thanks

    James

  • Søren Gregersen 441 posts 1884 karma points MVP 2x c-trib
    Mar 19, 2018 @ 03:36
    Søren Gregersen
    100

    Hi,

    You need to parse the JSON before rendering it.

    The easiet is to just create a view that can take care of just this. A better solution is to create a PropertyValueConverter. Either solution would/should give you a value with “Souce” and “Quote” properties.

    Have a look at this: https://our.umbraco.org/documentation/Extending/Property-Editors/value-converters

  • James 10 posts 50 karma points
    Mar 19, 2018 @ 22:10
    James
    0

    Thanks! This is exactly what I needed.

    For anyone else who stumbles upon this I found the following blog and and forum posts to be helpful.

    http://skrift.io/articles/archive/custom-property-value-converters/

    https://our.umbraco.org/forum/umbraco-7/developing-umbraco-7-packages/61760-A-question-about-property-converters

Please Sign in or register to post replies

Write your reply to:

Draft