What the heck is a Umbraco property editor value converter?


Published on

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

What the heck is a Umbraco property editor value converter?

  1. 1. What the heck is a Umbraco property editor value converter? Jeavon Leopold - Twitter: @crumpled_jeavon e: jeavon@crumpled-dog.com www.crumpled-dog.com
  2. 2. 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
  3. 3. 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
  4. 4. 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
  5. 5. 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
  6. 6. 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
  7. 7. 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
  8. 8. Thank you.Crumpled Dog Design - 18 Phipp St, London EC2A 4NU020 7739 5553 | jeavon@crumpled-dog.com | www.crumpled-dog.com