What is the best practice for interactions between theme and module ?

Topics: Customizing Orchard
Aug 9, 2013 at 2:38 PM

I have a custom theme and i want to show in the top of the screen the name of the current module and a drop down list to select the context of the module (For exemple the current module would be an application that presents the orders of clients and the context selector would present all the clients availables to the user).

Currently i have an AppContext module which is filled by the current module with its name and the list of clients.
And the theme gets these informations from the AppContext module.

I would have prefered to implement in each module a ContextProvider and have the theme request the context of the current module.
Is there a way to accomplish that ?
Or maybe there is a better way that could make the theme independant of modules (using widgets for example).


Guy Lescalier
Aug 9, 2013 at 3:16 PM
It's not quite clear what you are trying to achieve, but it is possible to get a reference to such a provider through WorkContext.
Aug 9, 2013 at 3:49 PM
Thanks for your answer, i'll try to make this clear.

The modules I create for my Orchard are independant applications.
So I created a theme with a top banner and above the application itself.
The banner is separated in two parts. The first to give informations about the application (name, context dropdown). The second is the global part (login, notifications, send feedback, parameters).

So as you can see i want to display in the banner (the theme) informations from the current application (module).

I saw that in the WorkContext there is a Resolve method but in my case i would have one implementation per module/application and i want Orchard to get the one from the current module (the module that owns the current url).
Aug 9, 2013 at 3:54 PM
I see. The right way to do that is that your module creates shapes, for which there are default templates in the views folder of the module. A theme can override any of those templates, or just change CSS. In any case, the theme never needs to know anything more than the "shape" of the shapes it overrides the templates for. That's as decoupled as it gets. Makes sense?
Aug 9, 2013 at 5:09 PM
I'm not yet quite familiar with the shape concept so i'm gonna check it out.
I'll let you know if that did the trick.
Aug 22, 2013 at 3:09 PM

I finally did this with a widget !

Thanks for the trail, it was really helpful.