Role Precedence and Sortable Widgets

One thing I really enjoy about Drupal 6 is increased emphasis on using the sortable UI widget in place of weighting wherever doing so enhances the interface and makes getting the job done easier.

We're all likely familiar with the use of block and menu sorts in D6 by now, and maybe have grown to take advantage of such things without giving them a second thought, too.

Perhaps one place where the sortable needs a second thought is the scenario I recently encountered, where a module used sortable user roles. This was likely the first time I'd encountered this UI element in a part of an interface where I completely glossed over it's intended use.

The interface looked kind of like this- and I'd happily went about my way, making appropriate changes, and then wondering why they didn't quite seem to have the intended effect.

Screen shot of Better Formats UI

You see, I have been sort of conditioned to look at that UI element as a way to arrange the presentation of items, and in the interface in question (part of the Better Formats module), I didn't realize that the different filters could (and should, at least in my case) be dragged around to set the precedence for each role, as such:

Screen shot of Better Formats UI

Sure, this could be a bad design decision or bug in the module. It likely should infer that user created roles probably take precedence over the built in roles, and order them appropriately by default, but in this case, and as of this writing, it doesn't.

So a funny thing will happen if one doesn't drag the roles into an order that makes sense, and you might be left in a head-scratching moment. ;-)

Moral of this post is generally to be aware that the ordering of some items carries different meanings in different contexts, affecting both presentational parameters, and module logic at times.

It is worth noting that if you're the sort who snarfs a module into a given site from a shell prompt, and then begins tinkering with it straight away, without ever glancing at the module page on d.o, that you might miss these little oddities spelled out in plain site.

To the credit of the author of the brilliant Better Formats module (it's a module that adds a level of flexibility core's own input format handling should probably already have), the module page points out, with an Important heading: (and I'm paraphrashing here) "hey dummy, pay attention to the role sort!"

So there you have it. Better Formats is an awesome module providing some great enhancement to Drupal's input formats, and helps remind one to also pay attention to how the sortable widget is being used in the interface!