Relative path to resources in Orchard modules

Topics: Writing modules
Aug 14, 2012 at 11:11 AM

I need to locate in view some path of image file and swf file wich placed in modules folder e.g. ModuleName/Resources/images and ModuleName/Resources/swf. I founded method like this:

<img src="/Modules/ModuleName/Resources/image/img.jpeg" />


flowplayer("player", "/Modules/ModuleName/Resources/swf/flowplayer-3.2.14.swf");


Question: Can I locate this resource in beter way such a wecan locate javascripts and styles

 public class ResourceManifest : IResourceManifestProvider {       

public void BuildManifests(ResourceManifestBuilder builder) {            builder.Add().DefineStyle("SomeStyle").SetUrl("style.css");            builder.Add().DefineScript("Somejs").SetUrl("Javascript.js");           

       }    }

and use in view  in way like a 



If such way exists please give me link or example

Aug 25, 2012 at 1:09 AM

I haven't tried it, but it seems like you could define any type of resource using builder.Add().DefineResournce() and then include that resource from your view using ResourceManager.Include or .Require.

Alternatively, you may want to consider creating an Url helper that would automatically resolve the correct path using the IExtensionManager to get the path to the current module

(e.g. var moduleDescriptor = extensionManager.GetExtensionById(Assembly.GetExecutingAssembly().GetName().Name);
var path = moduleDescriptor.Location + "/" + moduleDescriptor.Id + "/resources/".

As a matter of fact, such an extension method already exists for themes:

public static string ThemePath(this HtmlHelper helper, ExtensionDescriptor theme, string path) {
            return theme.Location + "/" + theme.Id + path;