"Routing" for css / js files?

Topics: Customizing Orchard, Troubleshooting, Writing modules
Sep 20, 2011 at 3:42 PM

Hi guys,

If one views the source of an html page in Orchard you can see full urls to css and js files.. e.g.

 

<link href="/Modules/MyApp.HelloWorld/Styles/MyStyle.css" rel="stylesheet" type="text/css" />

 

 

Is there any way of applying [something similar to the concept of] routing for this so it can become e.g.

<link href="/Modules/Foo/Styles/MyStyle.css" rel="stylesheet" type="text/css" />

 

Any help much appreciated :)

Coordinator
Sep 20, 2011 at 5:40 PM

Yes it is. Download the SuperClassic theme from the gallery, or browse the source code online for this file: http://orchardsuperclassic.codeplex.com/SourceControl/changeset/view/c88ade4c77ba#Routes.cs

This redirects to a controller which will generate a css dynamically, but you could also return a static file of your choice, or even a permanent redirect.

The other solution is to use the Rewrite Rules modules from the gallery, where you can define a RewriteRule like this:
Rewrite ^Modules/Foo/Styles/MyStyle.css$ /Modules/MyApp.HelloWorld/Styles/MyStyle.css

 

 

Sep 20, 2011 at 6:21 PM

You, sir, are a hero!

Developer
Sep 20, 2011 at 10:25 PM

Dont stroke his ego! :)

Coordinator
Sep 20, 2011 at 11:20 PM

Too late Nic