What the heck is a Umbraco property editor value converter?
What the heck is a Umbraco property editor value converter? Jeavon Leopold - Twitter: @crumpled_jeavon e: email@example.com www.crumpled-dog.com
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)10/04/2013 You are on page 2
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 10/04/2013 You are on page 3
How is this useful? • In MVC (typed), definitely no better Pretty complicated for a front end developer trying to do some basic Razor templating? With a property editor value converter implemented on MNTP (using dynamics) Definitely better Complicated now? • Doesn’t matter if XML or CSV storage type used by MNTP, the converter takes care of it • Implemented in both Typed and Dynamics10/04/2013 You are on page 4
How to implement a converter? Implement IPropertyEditorValueConverter • Found in Umbraco.Core.PropertyEditors namespace • Two methods: IsConverterFor & ConvertPropertyValue • Use UmbracoHelper if it helps Example converter for Content Picker10/04/2013 You are on page 5
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 slideshow10/04/2013 You are on page 6
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/PropertyEditorValueConverters10/04/2013 You are on page 7
Thank you.Crumpled Dog Design - 18 Phipp St, London EC2A 4NU020 7739 5553 | firstname.lastname@example.org | www.crumpled-dog.com
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.