What does it mean to have a feature enabled?

Topics: Administration, Core, Customizing Orchard, Writing modules, Writing themes
Aug 22, 2012 at 8:27 AM

I see that Orchard is built of features; I see that I can mark classes with an OrchardFeatureAttribute; I see that I can describe my feature in the manifest file and I see that I can enable a feature through the admin panel. 

Now for the questions. What does it mean for a feature to be enabled? Reading through the code, I believe that this means that classes marked with the appropriate OrchardFeatureAttribute will be registered with Autofac. Is this correct?

Regarding theme-features, I see that Orchard has the odd capability of enabling a theme that is not set to be the current theme. Looking through the source code, I believe that what I am seeing is that a non-current, enabled theme means that all features within that theme are enabled. Does this mean that classes in a non-current, enabled theme are being resolved? This seems like it could lead to some strange side effects if people started putting strange features into themes. 

To continue that thought, I also noticed that once I use a theme, it becomes enabled. If I switch to another theme, the previous theme is still enabled. I have to manually disable it. 

http://docs.orchardproject.net/Documentation/manifest-files

http://docs.orchardproject.net/Documentation/Enabling-and-disabling-features

Cheers,

Phillip Scott Givens

 

Developer
Aug 25, 2012 at 3:23 AM

As far as I know, this is all by design. One theme can inherit from another theme, so it makes sense that multiple themes can be enabled. The current theme may inherit zones, features and templates.

Coordinator
Aug 26, 2012 at 8:40 AM

There is also a possibility to implement an IThemeSelector to choose dynamically between active themes. One application could be to apply mobile themes depending on the user agent.

Sep 3, 2012 at 10:29 PM

Thank you for your replies. I am not sure that I got my main question answered though. Here it is again.

Now for the questions. What does it mean for a feature to be enabled? Reading through the code, I believe that this means that classes marked with the appropriate OrchardFeatureAttribute will be registered with Autofac. Is this correct?

Also, I apologize for my late reply, I did not see an email come through that there were responses. 

Sep 4, 2012 at 8:12 PM

You understanding of OrchardFeatureAttribute I think is correct.  From http://orchard.codeplex.com/discussions/349896:

The reason of having the OrchardFeatureAttribute is to cut the number of classes being registered in Autofac - for performance reasons. If it wouldn't be there - every class in a module having a couple of features would get registered no matter if it belongs to a disabled feature or not. Unnecessary load.

Hope this helps.

Sep 4, 2012 at 9:08 PM

Thank you David; that is the verification that I was looking for.

While re-reading my post, I realize that it may have been misread as though I was questioning the wisdom of such a design, which is not the case. Quite the contrary. I am about to embark on a non-CMS project which builds on the Orchard infrastructure and before I go spin my wheels on an incorrect assumption, I was looking for verification.