Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include a css stylesheet in Orchard module?

Tags:

css

orchardcms

I am working on a module for Orchard, and I just want to know how to include a css file.

I have done the following with no result:

Added a folder "Styles" to the root of my module and included a stylesheet and a Web.config file like in this question.

And I have seen this but that's not what I am looking for.

EDIT:

Ok, solution:

When I started working on Orchard I created a new module by just creating a new project in Orchard.Web/Modules folder, but as I read here, my Views/Web.config file has to include some orchard base things what mine didn't because I did not create the module using codegen. I fixed it now by replacing my Web.config file for a Web.config file from another Orchard module, now it works.

Next time I will use codegen to create a new module.

Thanks to endorphin for helping me!

like image 439
avb Avatar asked Dec 05 '12 09:12

avb


1 Answers

If you want to include your stylesheet in a view, you need to specify this at the top of your view. Where the name of your stylesheet is the filename of the .css file in the Styles folder.

So in your .cshtml file for your view..

@{
  Style.Include("your-stylesheet.css").AtHead();
}

I have used AtHead() in the past, but there are other methods to include your stylesheet in different locations (such as AtFoot())

If your stylesheet depends on other stylesheets you can do something a little more interesting by creating a Resource Manifest which is detailed here https://stackoverflow.com/a/6500121/580101

like image 106
endorphin Avatar answered Nov 15 '22 03:11

endorphin