Friday, October 29, 2010

New in JUNO, Data Editor Settings

As you may know, the main focus for Umbraco Juno is the starter kits and skinning (so aimed at making it easier to get started with Umbraco), if you're a seasoned Umbraco developer you'll most likely start with a clean Umbraco installation (and don't care that much about the starter kits).But we're also introducing a new developer feature in Juno, that should make one of the more difficult items in Umbraco a lot easier!

Creating custom datatypes

Creating your own data types is very easy when using the usercontrol wrapper method but once you want custom settings you won't be able to do that using the usercontrol wrapper but instead you'll need a custom data editor and for settings you'll need to create a custom prevalue editor class which is basically a custom control that allows you to setup the settings for a data type.

Introducing data editor settings

By using the new DataEditorSetting attribute you'll be able to dynamically generate the data type settings editor, eliminating the need for a custom prevalue editor class.

100 lines of code reduced to 2

The data editor settings should be a huge time saver for Umbraco devs since there is no more need to create a custom prevalue editor class anymore (and taking care of the whole crud of the settings), but it's just a matter of adding a property on your AbstractDataEditor and marking that with the DataEditorSetting attribute.

Sample:

[DataEditorSetting("Limit", description = "Maximum number of characters")]
public string Limit { get; set; }

Will result in this (if you don't specify the type a text field will be used):

image

So the custom prevalue editor class (which is easily around 100 lines of code) is simply replaced by a property and an attribute, it's that easy!

Also no more need to figure out how to use content pickers, media pickers, … Since its a breeze to use them, simply set the type to the one you want to use

[DataEditorSetting("Content picker demo",
type = " umbraco.editorControls.SettingControls.Pickers.Content, umbraco.editorControls",
description = "content picker")]
public string TestContentPicker { get; set; }

Result:

image

21 Default data editor setting types

If you don't specify the type a simple text field will be used, but there are 20 other controls available out of the box.

  • Checkbox
  • Checkbox list
  • Content Picker
  • Content Picker with XPath option
  • Date picker
  • Date picker with time
  • Dropdown list
  • Document type picker
  • Field picker
  • List box (select single item)
  • List box multiple (select multiple items)
  • Media picker
  • Media type picker
  • Member group picker
  • Member type picker
  • Path picker
  • Password
  • Radio button list
  • Text area
  • Values

And how they look:

image

This should cover all of the common controls used in the data type editor and of course it's possible to extend Umbraco and create your own custom data editor settings types.

Default values

It's also possible to provide a default value, by simply supplying the defaultValue param in the attribute

[DataEditorSetting("Limit", description = "Maximum number of characters", defaultValue = "500")]
public string Limit { get; set; }

Want to give it a try? Download the latest nightly build of Juno.

Want to be updated on everything Umbraco?

Sign up for the Umbraco newsletter and get the latest news and special offers send directly to your inbox

Are you sure, that's your real e-mail?