Since on this blog I have several posts about creating datatypes (using the various methods), I thought I’d also show how easy this has become in umbraco Juno, since you can combine the usercontrolwrapper with dataeditorsettings.
I’m creating the same datatype again, a textarea that has a limit on the number of characters, you can set the limit on the datatype settings
Sourcecode (including using statements it’s just 35 lines of code):
Umbraco 4.6 (Juno) makes it super easy to create custom datatypes with settings (even ones created with the usercontrol wrapper) with the introduction of data editor settings. By default there are 21 types you can use out of the box (textbox, content picker, path picker, … ) and off course it’s also possible to plug in third party types let’s take a look at an example:
This will output a dropdownlist that let’s you choose between the available connectionstrings ( found in the configuration / connectionStrings part of the web.config)
Umbraco 4.6 Beta (Juno) went out a couple of days ago, this is just a quick post highlighting one of the improvements.
As you may know if you want to register an xslt or rest extension you’ll need to do this in a config file (config/xsltextensions.config and /config/restextensions.config) but now with umbraco 4.6 you’ll be able to do this with some attributes instead.
So no more messing around with the config files(although they still work) but simply add a reference to the umbraco assembly and then you’ll be able to use the XsltExtension, RestExtension and RestExtensionMethod attributes to mark your extensions.
You can either place the .cs file in the App_Code folder of your umbraco installation or build the solution and place the assembly in the bin directory.
Just a quick post showing the impact of the DataEditorSettings attribute coming in umbraco Juno (making creating datatypes with custom settings super easy). If you attended the level 2 course this will look familiar, since in the course you learn how to create custom datatypes with the usercontrolwrapper, by making a dropdown that populates from a 3rd party db. Since with the usercontrolwrapper method you don’t have a way of setting up settings for your datatype you’ll basically hardcode the connectionstring, select statement, … Now in this example I also create a dropdown that can be populated with data from a db and in the setting of the datatype you simply set the connectionstring, select statement, text column (what will be shown in the dropdown) and value column (what will be saved).
Datatype in action:
publicclass DbDrivenDropdown: AbstractDataEditor
private DropDownList control = new DropDownList();