0 Comments

Umbraco allows you to write a custom converter for the datatype, so as to you can use strong type object. For example the standard Umbraco Core "Content Picker" stores a nodeId as String type. However if you implement a converter it could return a IPublishedContent object.

 

What is Property Value Converter

A property value converter converts a property editor database stored value to a strong type. The converted value can be accessed from MVC Razor or any other Pulished Content API, defined by Umbraco.

How to create a custom property converter

Here is an example to convert RelatedLink value into a IList<RelatedLink> object.

RelatedLink object looks like this

image

 

Implement custom converter RelatedLinksPropertyConverter by inheriting from PropertyValueConverterBase, and IPropertyValueConverterMeta. The custom converter looks like this

image

NOTE: the custom converter need to follow name convention  [DateType]PropertyConverter

References

https://our.umbraco.org/documentation/extending/property-editors/value-converters

Post comment