5 Umbraco packages you can´t live without!

This is our list of packages for Umbraco that we work with on a daily basis and couldn´t live without.

  1. Desktop Media Uploader
    Awesome package by Matt Brailsford that enables you to batch upload media with folder structure intact. We use it to upload everything, even if its just a singel image.
  2. UnVersion
    Another awesome package by Matt Brailsford that enables you to turn off version control on specific document types. Perfect if you for example import articles with CMSImport on a scheduled basis.
  3. 301 URL Tracker
    It´s a must for all websites, that keeps track of renamed and deleted documents. It also has the ability to help with 301 when you migrate from another system. This should defenetly be in the core om V5! Thanks Stefan Kip!
  4. ImageGen
    This package by Douglas Robar is used att all times. It enables you to automaticly resize and crop images. We use PRO version for 60% of all our websites.
  5. CMSImport
    This package enables you to import stuff into both content, media and members. It also has a scheduler in the PRO version. We use this to import products and its structure from ERP-systems directly into Umbraco content nodes. Thanks Richard Soeteman!
Posted by Kalle Ekstrand at 09:22
Tags :

If your uBlogsy blog in umbraco won't accept comments...

You may have noticed that we've had this problem on this blog on and off from day one. Incredibly annoying because we haven't gotten the praise that we have earned and that motivates us so immensely... :)

The solution: Make sure you have a URL and a language configured on the uBlogsy landing page or higher up in the hierarchy. Right click the node, it's under "manage hostnames".

We currently use English, but I suspect any other language will work just fine as well.

Presumably, uBlogsy does some langauge-related stuff when a comment is posted, and barfs when no umbraco language is defined (in my mind, there ought to be a default somewhere, but maybe not).

And don't ask me how I came up with the idea to make that change - I honestly don't have even a hint of a clue. Divine inspiration, perhaps... :)

Caveat: This fix was implemented ten minutes ago... so... I have no proof that it works longer than that.

Posted by Peter Josefson at 14:25
Tags :

Using media picker in umbraco backend

I've seen many questions on this in the forums, and no good answer. It has even been reported as a bug, but closed. So... when I needed the functionality myself, I took a look at the umbraco sources and figured out what's wrong.

It may not be a bug, but it's definitely a weird quirk. The workaround is simple though. But let's begin at the beginning...

The Problem:

A media picker on a custom editor page doesn't show any value when the page loads, although there is a value and it is set during Page_Load or OnLoad. Or, in more detail:

  • You write a custom section with some kind of data editor that works against a custom database (i.e. doesn't use umbraco documents or other objects).
  • You want to let the user pick media items from umbraco and save their id:s in your database, so that you can render them in your usercontrol (or whatever you use to present the data in the frontend).
  • You read a HOWTO on this and pick a media picker (almost any - most seem to work the same way), for example the mediaChooser.
  • You test it, pick a media item and it works. It gets saved in the database.
  • You return to edit your data, but the media item is GONE. It (the ID) exists in your database, but not in your custom editor. You set it in Page_Load (as you would normally do with control values), and you've triple-checked that. Still doesn't work.

The Cause:

The mediaChooser (and - from what I have seen - most other media pickers as well) handles its value in an unexpected way. More detail:

The mediaChooser behaves like this (or actually the BaseTreePickerEditor, which mediaChooser inherits from - and I suspect most other media pickers do that as well):

  • In OnInit, if an IData object was presented by the constructor, its "Value" property is saved in a private variable. If IData is null, the value will be -1.
  • In OnLoad, the Value property of the control (which is defined by a base class) is overwritten by the value in the private variable.
  • In all the following stages, the Value property is used (as it would normally be).

This is a bit weird, as you usually create your controls in OnInit and populate them with data in OnLoad. There are other ways and other events that serve to make the process even more granular, but that is the most common pattern in examples and so on. The mediaChooser, on the other hand, assumes the data will be present in the extractor already upon initialization.

This may be an umbraco convention (I haven't looked at the source for other data editors), but in any case, it is unusual, and probably quite unexpected for most people.

The Workaround:

Set the value of the media picker in OnPreRender instead (or any other event that occurs after OnLoad but before rendering) of OnLoad or Page_Load. If the data is only available during OnLoad, stash it away in a private variable then, and stick it in yourPicker.Value during OnPreRender.

Works like a charm.

Oh, and one more thing:

You don't need a value extractor (an object of a class that implements the IData interface). Just pass null for that parameter of the mediaChooser constructor, and use the Value property instead. It should be "" when no media item is selected - otherwise, it should be the media ID as a string.

Further reading:

ASP.NET Page Life Cycle Overview (a must-read for all ASP.NET developers)

mediaChooser.cs source

BaseTreePickerEditor.cs source (inherited by mediaChooser)

BaseTreePicker.cs source (inherited by BaseTreePickerEditor)

Posted by Peter Josefson at 22:45

Custom section - moving away from content after delete

When you build a custom section (or tree) in the backend, and have a delete action on your nodes, you don't want the right-hand frame to stay on the deleted object after a delete. The user may be tempted to click save, and unless you're prepared for that, things will go sideways.

So, you want to return to your dashboard (or the default - empty - page) after deleting the node.

Umbraco itself doesn't handle this in all places, but after diving deep into the umbraco javascript source, I found a hack that works.

In your BaseTree implementation, in the RenderJS override, add this javascript snippet:

function toxicOnDeleted(EV)
{
    UmbClientMgr.appActions().openDashboard('toxic');
}
UmbClientMgr.appActions()
    .addEventHandler('nodeDeleted', function(E) { toxicOnDeleted(E); } );

 

I have several trees in my section and i only run this in ONE of them (it will fire for any node in any tree in the section).

I'm not entirely sure if I should find some way to unregister the eventhandler (or protect it from being registered more than once), but in any case, it works for now.

Any other solutions - or additional thoughts - out there?

EDIT: I tried to figure out a way to see which node had been deleted, but ran out of time. It seems that the event argument doesn't contain anything useful, but the node id or alias may be available elsewhere. If anyone has any intel on this, please let me know.

Posted by Peter Josefson at 11:16
Tags :

Making umbraco language file changes take effect

This is already documented in forum posts, but the more ways there are to find this kind of information, the better... took me a while to find. To the point:

You may have experienced that when you change something in one of the NN.xml files under /umbraco/config/lang (such as a custom section name), nothing happens. Nothing at all.

The cause:

The translated texts are cached in javascript snippets by the client dependency system, and never (to my knowledge) refreshed.

The fix:

1. Delete the folder /App_Data/TEMP/ClientDependency (if there is one in App_Data as well, kill that as well - that's the location in older versions).

2. Touch your web.config (or use whatever favourite method you have to restart the application).

The folder and its contents will now be recreated (and up to date).

EDIT: For a more permanent fix on a development server - see Eran's comment below. Use my fix after deploying new language files to produktion servers.

Posted by Peter Josefson at 16:46