Theme/Module dependencies

Topics: Writing modules, Writing themes
Dec 12, 2011 at 11:36 PM

Hi guys I have another question:

Is there a way to create Orchard themes and modules to have dependencies on each other?

I have a module that outputs things to certain zones but the zones are defined in a theme.  The module is meaningless unless that theme is involved, so I'd like for the module to be dependent on the theme.

Dec 12, 2011 at 11:56 PM

In that case that module's code should be part of the theme.

Dec 13, 2011 at 4:42 AM

So instead of having Theme A and Module A each enabled separately, you are suggesting that I move the code in module A into theme A.  

Okay.  That makes sense.



1. Can I have migrations in themes to define models and parts?

2. What do I do if I need to create module B, which depends on module A?  Can I make module B now depend on Theme A?

Dec 13, 2011 at 5:06 AM

1. You can, but they can only be run from the command-line (known bug:

2. No, but you just broken your own scenario: you said the module was meaningless outside of the theme. If that is not the case, then yes, it should be a module and your theme should have a dependency on it instead. But yes, theme-module interaction is not a perfectly well-rounded thing.

Dec 13, 2011 at 7:17 AM

I didn't realize that a theme can declare dependencies other than "base theme".

But it seems that it doesn't automatically enable the dependent modules ... it only gives a warning message.  Is there a reason for that?

Dec 13, 2011 at 7:32 AM

Dependencies here are meant as csproj dependencies.

Dec 13, 2011 at 7:35 AM

oh.  What happens if i deploy a theme and it has a csproj dependency on a module that is not enabled (or worse, not installed)?  wouldn't it die?  or does it prevent activation?

Dec 13, 2011 at 7:38 AM

I don't know. One would have to try.

Dec 13, 2011 at 7:42 AM

ok thanks =)

I appreciate your quick and concise responses.