Archief

Dev

Multiple features in one orchard module

When you’re creating multiple features in an Orchard module, it’s important to specify of each class for which feature it’s needed. The Q42.DbTranslations module for instance, contains two features: Q42.DbTranslations and Q42.AdminCultureSelector.

First attempt I only decorated the Handler to be specific to this feature:

[OrchardFeature("Q42.AdminCultureSelector")]
public class AdminCultureSettingsPartHandler : ContentHandler
{
  public AdminCultureSettingsPartHandler(IRepository<AdminCultureSettingsPartRecord> repository)
  {
    Filters.Add(new ActivatingFilter<AdminCultureSettingsPart>("Site"));
    Filters.Add(StorageFilter.For(repository));
  }
}

I expected the AdminCultureSettingsPart not to be attached to Site, and therefore the whole feature would be disabled. But alas, it didn’t work. So I decorated the Part, the PartRecord and the Driver with OrchardFeature, and that fixed the problems.

But then you’re not there yet. Because when you have multiple features in a module, everything that isn’t specifically decorated with an OrchardFeature, is automatically allways enabled. So everything specific for DbTranslations also needed to be decorated.

Actually, every class except Migrations needs to be decorated, when you have multiple features in one module. In the end I decided to split the two and create separate modules for them :)

#features #modules #orchard