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.


[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):


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; }



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:


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.

If you don't know Umbraco, here are some numbers behind the world's friendliest CMS

One of the biggest benefits of using Umbraco is that the community is incredibly pro-active, extremely friendly and helpful.

Chances are that if you get an idea for something you would like to build in Umbraco, someone has already built it. So it is very likely that you can get good and friendly advice from someone from the Umbraco community on Our- just ask.

Number of active installs
Number of active members in the community
Known free Umbraco packages available

Want to be updated on everything Umbraco?

Be one of the first to know about special offers on our products and services. Get invitations to Umbraco events and festivals sent directly to your inbox.

All you need to do is get on our mailing list and soon you'll become a true Umbraco-know-it-all.

Sign up for Umbraco newsletters and offers

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