Mar 28, 2011 at 2:16 AM
Edited Mar 28, 2011 at 2:18 AM
I wanted to customise label texts of custom Fields (I'd already done most of the implementation before I found workitem
17255 which is basically the same thing). It was pretty straightforward to do.
I attach two patches containing my implementation. It adds DisplayName columns to ContentFieldDefinitionRecord and ContentPartFieldDefinitionRecord and surfaces this in the UI and field views (falling back to Name.CamelFriendly() otherwise).
There is one big (but not insurmountable) problem with this. NHibernate blows up with an error about DisplayName not existing in the database, so you can't get into the UI to actually run the migration (which I added in Orchard.Core.Settings
where those two tables are created). I got the migrations to run by first commenting out the DisplayName properties both Record classes and temporarily fixing references.
Then I could run the update, and finally reinstate DisplayName. So basically the migration needs to be run before the rest of the patch is applied. Is there any way in Orchard where a particular core update can be run before anything else tries to
load? I couldn't even run Orchard command line in that state. Or am I just missing some way to decorate the properties that will stop NHibernate blowing up?
Anyway, with the migration successfully run and the patch applied I now have a DisplayName on all my TextFields.
Unfortunately all fields need their views and drivers updating to reference DisplayName, there's no way to around this - Name is used in that context both for display purposes and as a key, and only Name is surfaced to when the driver displays it. But it's
a trivial change to make, and tutorials could be updated in the future to use DisplayName if this became part of core, which assuming the DB migrations can be overcome I'd be very happy to see :) (Unless there were already plans for this, and additionally
I haven't really considered localization; I've started thinking it might have been better to store the display names in a separate table which supported that scenario; any thoughts on this?)
Edit: Forgot to attach file, here it is: