Current Theme Name within view?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 10 ans
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?
Il y a 10 ans
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
Il y a 10 ans
why not load the files from your plugin content folder?
I will not be loaded twice, if the file exists on another page.
Il y a 4 ans
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";
}
Il y a 2 ans
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.