This project has moved and is read-only. For the latest updates, please go here.

handling css files as well .. for concideration

Feb 8, 2013 at 6:35 AM
I'm upgrading to 1.6 so I'm finding all my small changes and have one I've been meaning to suggest since forever (1.3)....

As a suggestion, the css module can be made to include .css files as well as .js files.

In CustomCssHandler.cs, functionBuildDisplayShape(BuildDisplayContext context) made a small change for your concideration... the middle "else if block" below allows inclusion of .css files. I use it on content items to include one-off css for a given page. Good practice or not, its handy.
                foreach (var script in scripts) {
                    if (script.EndsWith(".js", StringComparison.OrdinalIgnoreCase)) {
                        _resourceManager.Value.Include("script", script, null);
                    }

                    else if (script.EndsWith(".css", StringComparison.OrdinalIgnoreCase))
                    {
                        _resourceManager.Value.Include("stylesheet", script, null);
                    }

                    else {
                        _resourceManager.Value.Require("script", script);
                    }
                }
It add the appropriate markup to the head of the page i.e.

<link href="/OrchardLocal/Themes/MyThemes/css/homepage.css" rel="stylesheet" type="text/css" />
Feb 10, 2013 at 6:54 AM
Thanks.