Reputation: 19742
In my Orchard project I have a BaseTheme and a few themes that are derived from it.
In my BaseTheme I have a folder /Styles/Images
. I need to get a path to that folder in a JavaScript variable in order to pass it to UI components. In order to do that there is a view in the BaseTheme that is shared among all derived themes. In this view I have a piece of JavaScript code that gets the path:
var pathToImages = '@Url.Content(Html.ThemePath(WorkContext.CurrentTheme, "/Styles/Images/"))';
The problem is it only gets the right path when the view is rendered from the context of the BaseTheme. Each derived theme that renders this view gets an incorrect path, because the code that gets it explicitly says WorkContext.CurrentTheme (and thus this path is relative to the derived theme).
How can I get a path to resources that sit in the BaseTheme from a view that sits in the BaseTheme but is rendered from a derived theme?
Upvotes: 0
Views: 965
Reputation: 17814
You can use the application-relative path to the resource instead:
@Url.Content("~/Themes/NameOfTheBaseTheme/Styles/Images")
Upvotes: 1