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!
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.
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
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
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
is working on a reply...