Umbraco 5 Gems for Developers

Wednesday, July 13, 2011 by Aaron Powell

Another day and another Umbraco 5 Gems post is available. Today we'll be looking at what Gems there are for Developers with the Umbraco 5 release.
Umbraco has a great history of being highly flexible for people who want to extend it beyond just a simple CMS. In this article we're going to dive how we're making the CMS even easier to extend than before from the point of view of a developer working with the API or a developer wanting to create packages.
 

Searchable trees


Umbraco has had back office searching through a search box in the upper left corner of the content application, but the problem was it was limited and hard to plug your own trees into. If you wanted to have searching for your own back office application then you had to go about doing it as a dashboard application. While this is good (and still do-able in Umbraco 5) it did mean that you didn't have the ability to leverage the built-in UI of Umbraco.
Well with Umbraco 5 this has been addressed with a new interface, ISearchableTree. When implementing this interface whilst putting together your own tree, you'll be able to hook into the Umbraco UI for searching. What's really cool is that this is contextual, so if you create a custom tree which is loaded into an existing application, e.g. for content, searching will be targeted against that automatically.

 

The data layer is a Hive of activity, and the default content provider is NHibernate 3


Data in Umbraco 5 is the epitome of pluggable, and you can even merge multiple providers into one website. The primary, out-of-the-box provider for content, media, etc. in Umbraco 5 will be NHibernate (with Fluent NHibernate to make the mappings more robust). This means that there's no more embedded SQL, instead we can leverage the testability of an ORM. This also means that we can maintain our support for Microsoft SQL Server (including CE4) and MySQL.
It also means we're going to be having proper transactional data interaction so it'll be a lot harder to get yourself into a state where the Umbraco database is corrupt.
Hive is not just about traditional "database" data either: you can use it to plug in your own data for powering content, but we also use it for things like files meaning cloud storage feels no different to native storage, you simply swap out the provider in config. There are more details in Alex's talk from CodeGarden11.
 

Hive ID's are URLs


To tie in with the Hive in Umbraco 5 we've changed the ID scheme to not be just a number. This means we're able to store more information in the ID, and in fact the Hive will store two additional pieces of information, the "item type" e.g. content / media, and the provider.
The reason this is powerful is that because we're able to have different Hive providers listen for the URL scheme, and load the data from a different provider depending on the route or other rules.
In fact the different files in the application (CSS, JavaScript, DocType Icons, etc) are all loaded from a single Hive provider with different instances listening for different URL schemes, the CSS provider listens for storage://stylesheets where as JavaScript is storage://javascript, and so on. Even the "file upload" property editor uses Hive, but more on why that is awesome in a future post.
 

Simpler back office applications and trees


One thing we got from talking to package developers was that creating back office applications and trees could be quite tricky and even getting your own tree into an existing back office application could be difficult. In Umbraco 5 this has been changed so that it wont require these to be kept in the database, instead they are kept in the config. So with a simple change to config you'll be able to create a new application, move trees between applications, etc. Also these config options will be specific to your plugin so you don't need to worry about updating a global config file somewhere (more on Umbraco 5 configs below).
Additionally these will have an immediate effect on Umbraco so you don't have to log out or restart IIS (and t here's a really sexy little animation which you'll see to refresh the application icons!).
 

Plugins are not loaded into the /bin


When you've got an Umbraco site with many different extensions it's possible that you'll have a lot of assemblies in your /bin folder, but how can you keep track of what files belong to what package?
Again in Umbraco 5 we've decided to address this and in doing so we have elected to store plugin assemblies separately, in the plugin directory itself - and since each plugin is in its own folder, it'll be a lot easier to work out exactly what belongs to what files belong to what plugin.
Again to learn more about the v5 plugins I suggest you check out Shannon's talk.
 

Plugins use NuGet


Rather than maintaining our own plugin XML format we've decided to go with NuGet as our packaging format. NuGet is perfect for packaging since it has all the information we need for a plugin, a name, id, version, license URL, etc.
There is even a simple to use desktop tool (and command line) which will mean you'll be able to create packages from within the Umbraco UI and from outside the Umbraco UI.
Please note that in the CTP you're unable to create packages from the Umbraco UI, instead you need to use the NuGet desktop application. There's a good amount of information on the NuGet website which covers what NuGet is in more details and even a walk-through of how to create a NuGet package using the desktop application. There are a few differences though and again I suggest you refer to Shannon's talk for more about plugins in Umbraco 5.
 

Simplified configs


When we were speaking to package developers one of the primary things that they use the Package Actions in Umbraco 4 is to manage changing the configs for Umbraco. So a big goal of v5 was to make it easier for package developers to provide configuration information to Umbraco from a package without worrying about modifying the web.config of the website.
Since each plugin is in its own folder it also has its own config. When Umbraco 5 starts up it will parse all the configs for all the packages and produce a large view of the config state of the application. In addition all the configs will be loaded in a last-in order, so if you want to override something within either the root Umbraco config, or in another package, you will be able to. And when you uninstall a package the config will be removed too, rolling back to a pre-installed state.
This is known as the Deep Config Manager and it is responsible for the whole Umbraco 5 config. And don't worry, it still supports both app-settings and custom config sections depending on your personal preference.

So this brings us to the end of another Umbraco 5 Gems blog post. Hopefully some of the changes we've got around making Umbraco 5 an amazing development platform are tantalising for application and package developers. Stay tuned though, we've got more Umbraco 5 Gems to come.

2 comment(s) for “Umbraco 5 Gems for Developers”

  1. Gravatar ImageFrancois Payette Says:

    great to hear, about fluent and nhibernate, way to go.

  2. Gravatar ImageMikael Says:

    Hello!
    I´m trying to figure out how to cretae a serach box for my website wich run locally for the moment. I´ve only find guide for it at umbraco.tv with help from Examine but it doesn´t seems to work with Umbraco 5.

    how to do??

    Thanks in Avdvanced!

Leave a comment