More stories
Share
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.

Related Story

JUPITER: The journey has begun

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
443.450
Number of active members in the community
220.022
Known free Umbraco packages available
320

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 our monthly newsletter

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