8
What the heck is a Umbraco property editor value converter? Jeavon Leopold - Twitter: @crumpled_jeavon e: [email protected] www.crumpled-dog.com

What the heck is a Umbraco property editor value converter?

Embed Size (px)

Citation preview

Page 1: What the heck is a Umbraco property editor value converter?

What the heck is a Umbraco property editor value converter?

Jeavon Leopold - Twitter: @crumpled_jeavone: [email protected] www.crumpled-dog.com

Page 2: What the heck is a Umbraco property editor value converter?

What the heck?What is a data type property editor?• Property editors are the actual editors that are rendered to the content editors, implemented using

AbstractDataEditor or IUsercontrolDataEditor• Data types (stored in DB) implement a selected property editor (coded in C#)• Content values are stored as a string in prevalue(s) (often as CSV, Json or XML)

So what is a property editor value converter?• Introduced in Umbraco v4.10• Applies to MVC razor rendering only

(there is a similar mechanism for razor macros called Razor Model Binding)• Converts the stored content value string to some other type e.g IPublishedContent• Can be included with a property editor (especially if property editor is a package)

You are on page 212/04/2023

Page 3: What the heck is a Umbraco property editor value converter?

How is this useful?How many times have you had to split in Razor to use MNTP?• My version for Razor Macros:

• In MVC (using dynamics), a little better, maybe

You are on page 312/04/2023

Page 4: What the heck is a Umbraco property editor value converter?

How is this useful?• In MVC (typed), definitely no better

With a property editor value converter implemented on MNTP (using dynamics)Definitely better

• Doesn’t matter if XML or CSV storage type used by MNTP, the converter takes care of it• Implemented in both Typed and Dynamics

You are on page 412/04/2023

Pretty complicated for a front end developertrying to do some basic Razor templating?

Complicated now?

Page 5: What the heck is a Umbraco property editor value converter?

How to implement a converter?Implement IPropertyEditorValueConverter• Found in Umbraco.Core.PropertyEditors namespace• Two methods: IsConverterFor & ConvertPropertyValue• Use UmbracoHelper if it helpsExample converter for Content Picker

You are on page 512/04/2023

Page 6: What the heck is a Umbraco property editor value converter?

Quick demo• Fresh Umbraco v6.0.3 using NuGet• Install Standard Website MVC• Build MNTP Property editor value converter• Copy dll into solution• Update the Razor slideshow

You are on page 612/04/2023

Page 7: What the heck is a Umbraco property editor value converter?

More?Umbraco Core Property Editor Converter Package (Umbraco v6 only)• Implements converters for Umbraco Core property editors• Will hopefully be merged in Umbraco pre v7• http://our.umbraco.org/projects/developer-tools/umbraco-core-property-editor-converters• Check out the source code https://bitbucket.org/jeavon/umbraco-core-property-editor-converters• Helper method WIP – provides access to the data type settings so that you can alter the return type

depending on the settings

Documentation• http://our.umbraco.org/documentation/Extending-Umbraco/Property-Editors/PropertyEditorValueC

onverters

You are on page 712/04/2023

Page 8: What the heck is a Umbraco property editor value converter?

Thank you.

Crumpled Dog Design - 18 Phipp St, London EC2A 4NU020 7739 5553 | [email protected] | www.crumpled-dog.com