I am writing an Orchard theme, and I\'d like to be able to locate some of the resources packaged with the theme (images/swfs etc).
What is the best way of doing this
I slapped together an extension method for a similar problem:
public static string ResourceUrl(this HtmlHelper helper, string resourceType, string resourceName)
{
var manager = helper.Resolve();
var settings = new RequireSettings { Type = resourceType, Name = resourceName, BasePath = resourceType };
var resource = manager.FindResource(settings);
var context = new ResourceRequiredContext { Resource = resource, Settings = settings };
var url = context.GetResourceUrl(settings, "/");
return url;
}
Resource Manifest Definition:
manifest.DefineResource("Content", "MyImage").SetUrl("Content/myimage.png");
View Usage:
@Html.ResourceUrl("Content", "MyImage")
It's not well tested, and could probably use some error handling, but its working for me.