Umbraco 4.6 (Juno) introduces the data editor settings which make it a lot easier to create datatypes with custom settings (including datatypes created with the usercontrol wrapper method).
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)
ddl.Items.Insert(0, new ListItem(String.Empty, String.Empty));
ddl.SelectedValue = _val;
return ddl;
}
}
}
Simply inherit from DataEditorSettingType (found in the umbraco.cms.businesslogic.datatype namespace) and override the value property and the RenderControl method.
Now to use this type as a setting on your custom datatype, simply mark a property with the DataEditorSettings attribute and set to type to the created data editor setting type
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.
using System;
using umbraco;
using umbraco.presentation.umbracobase;
namespace UmbracoJunoTest
{
[RestExtension("TestAlias")]
[XsltExtension]
publicclass Test
{
[RestExtensionMethod]
publicstaticstring HelloWorld()
{
return"Hello World";
}
}
}
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.
Instead of having a previous and next link when you want to add pagination to a list of items I wanted to try to load in the next page when the users scroll down to the latest item.
It’s actually pretty easy todo thanks to a jQuery plugin jqPageFlow, that takes care of fetching the records when the user scrolls down.
What the plugin needs is just a page where it can fetch the records (and it passes the page number as a querystring parameter)
So, all I need was a little xslt macro (very similar to the pagination one) and a alternative template (that is used in the background to fetch the items).
If you have a multistep form in Contour and the end users doesn’t fill in all the steps, the next time he visits the form he can simply continue where he stopped…
Currently it isn’t possible to disabled this resume funtionality in the UI but it’s pretty easy to do, it’s just a matter of removing a cookie.
Here is a snipped you can use (just make sure to set the correct form guid):
<script runat="server">
protectedoverridevoid OnLoad(EventArgs e){
if (!IsPostBack)
{
int pageId = umbraco.presentation.nodeFactory.Node.GetCurrent().Id;
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).
Settings editor:
Datatype in action:
Complete sourcecode:
using System;
using System.Data;
using System.Web.UI.WebControls;
using umbraco.cms.businesslogic.datatype;
namespace DataEditorSettings.Demo
{
publicclass DbDrivenDropdown: AbstractDataEditor
{
private DropDownList control = new DropDownList();