< ALL BLOGS Importing Documents ... >

Custom DataTypes in Umbraco

  • 11.09.11
  • Ricardo Acevedo
cms

Umbraco, an Open Source CMS built on the Microsoft ASP.NET Framework. Umbraco makes it easy to implement custom datatypes using the built-in usercontrol wrapper to configure a custom property within a pre-created Document Type.

There are some many cases when a custom datatype will be really useful instead of using one of the built-in Umbraco’s datatypes, in this example we will create a custom datatype to store information of each content item:

  • Owner Name
  •  Owner Role
  •  Creation Date
  • and Modification Date   

This simple form will display regular .NET controls like textboxes and calendars. The first step is to add a reference to the umbraco.editorControls assembly.

To create a custom control, you must:

  1. Add a new user Control to our usercontrols folder
  2. Add the user control mark-up




  3. The new usercontrol implements the umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor interface, and then implements the interface member value.
  4. Define the Umbraco value on postback.
  5. Move all the new components to your Umbraco folders.
  6. Go to Umbraco control panel and click on “Developer” section.


  7. Create a new Data Type called: CustomDataType.




  8. Select the Umbarco usercontrol wrapper as “Render Control”, and then click “Save” to enable extra options.


  9. Select our new usercontrol in the “Usercontrol” option.

  10. Go to the “Settings” section to add a custom properties on a selected Document Type. 


  11. First, add a new Tab. For this example, we’ll call it MyTab. the new tab can be added in the “Tabs” settings.


  12. Then go to the “Generic properties” and click on “Add New Property”. Here you can enter the Property Name, Type (select our CustomDataType), and the Tab to be displayed (select our MyTab), finally click on “Save”.

    To see our new changes, we can create a new content item of the same document type we have selected. We can also see our changes in the created content items of this document type

  13. Go to “MyTab” and you will see our custom datatype.

    When you click on “Save”, the Umbraco value member is assigned and the value is stored. You can click on any other item and then go back to confirm that our custom datatype is showing the saved information.

    In the end, you can see how easy is to extend data-types functionality in Umbraco, this really useful feature can save a lot of time and improve the way we manage content’s  properties, using the .net framework is easy to implement any custom functionality that simply integrates with Umbraco.


Subscribe to our blog

*

Subscribe to Our Blog
*

Featured

2017 copyright Oshyn. contact us //  privacy policy