CSS selection based on layer name.

Topics: Writing themes
Mar 19, 2012 at 12:22 PM
Edited Mar 20, 2012 at 1:16 PM

Using Theme machine as example, I want to create slightly different pages based on one Layout.cshtml. For example on the home page width of AsideFirst element is 200 px and for other pages it needs to be 400 px. I have created following layers: one with rule url("~/") and other with rule not("~/"). Based on layer names I want to include home.css OR content.css on my Layout.cshtml. It's a simplified version of what I want to receive as output.

I find only one solution for this, but it's not used layers in base. For resolving css we may use current path: 

Style.Include(Context.Request.AppRelativeCurrentExecutionFilePath == "~/" ? "home.css" : "content.css");

But this solution is not suitable for my needs. I do not want to list all possible paths in Layout.cshtml.

How can I link current layers with my css files?

Maybe I thinking in wrong direction and this scenario could be solve with different approach.

Apr 20, 2012 at 1:57 PM

Any ideas on this?

What I need is for layer "Home" use home.css and for layer "Content" use content.css. Is it possible that in Orchard has module for my purpose? Or maybe my approach is wrong?

Apr 20, 2012 at 10:26 PM

layers are for widgets. You'll have to write your own code for that.

Apr 20, 2012 at 10:26 PM

You could use a layout alternate for the homepage instead.