how to place module's css after Site.css

Topics: Troubleshooting, Writing modules
Jun 9, 2012 at 11:51 AM

Hello! In my module, I have a CSS file, which is defined in ResourceManifest.cs. I include it in my View via Style.Require("MyModule");

The resulting HTML includes MyModule.css before Site.css from my theme. And I would like it vise versa -- MyModule.css after Site.css, so that it could redefine some of the theme styling.

Is it possible? Maybe I should somehow set a dependency on Site.css in my ResourceManifest?


Jun 9, 2012 at 2:37 PM

Although I ain't sure, I don't think that's possible right out of the box. Which makes sense, since the whole purpose of a Theme is to override views and styles from the various modules, including your own. Modules come with default views and styles; Themes override them, and not the other way around as you seem to be looking to achieve.

That being said, why don't you include the module's style syeet with your theme?

Jun 9, 2012 at 6:14 PM

Like sfmskywalker says, themes always take precedence. If you add the link tag referencing the stylesheet directly to the layout however (i.e. not through the ResourceManager as it happens with Style.Require()) you can freely decide where it should be placed. Look at the Theme Override module for an example.

Jun 10, 2012 at 7:37 AM

Thank you for replies. Yes, I can now see that it is a valid point -- theme taking precedence. The problem was those two css files came as legacy from an mvc applicatoin that is now being turned into an orchard module, so I wanted to keep changes to a minimum. But it is probably worth refactoring css anyways.