Current Theme Name within view?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 10 años
Is there capability to get the current theme name within a view?

The current theme name is needed for plugins that have custom JS and CSS files which need added (example below):

@Html.AddScriptParts("~/Themes/" + CurrentThemeName + "/Content/custom.js");


Or, perhaps there is an alternative/better approach?
Hace 10 años
breakskater wrote:
Is there capability to get the current theme name within a view?

The current theme name is needed for plugins that have custom JS and CSS files which need added (example below):

@Html.AddScriptParts("~/Themes/" + CurrentThemeName + "/Content/custom.js");


Or, perhaps there is an alternative/better approach?


ThemeContext should do the trick. :D
Hace 10 años
why not load the files from your plugin content folder?
I will not be loaded twice, if the file exists on another page.
Hace 4 años
breakskater wrote:
Is there capability to get the current theme name within a view?

The current theme name is needed for plugins that have custom JS and CSS files which need added (example below):

@Html.AddScriptParts("~/Themes/" + CurrentThemeName + "/Content/custom.js");


Or, perhaps there is an alternative/better approach?



@inject Nop.Web.Framework.Themes.IThemeContext themeContext
@{
    var themeName = themeContext.WorkingThemeName;
    Layout = $"~/Themes/{themeName}/Views/Shared/_ColumnsOne.cshtml";
}
Hace 2 años
Arash is right. But in my case, I'm using it like this:

@using Nop.Core.Infrastructure
@using Nop.Web.Framework.Themes

@{
var themeName = EngineContext.Current.Resolve<IThemeContext>().WorkingThemeName;
}

@Html.AddScriptParts(string.Format("~/Themes/{0}/Content/custom.js", themeName));
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.