Here is my customViewEngine:
public class CustomViewLocationExpander : IViewLocationExpander
{
private const string THEME_KEY = "nop.themename";
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
{
if (context.Values.TryGetValue(THEME_KEY, out string theme))
{
viewLocations = new[] {
$"/Themes/{theme}/Views/{{1}}/{{0}}.cshtml",
$"/Themes/{theme}/Views/Shared/{{0}}.cshtml",
$"~/Plugins/misc.pluginName/Themes/{theme}/Views/Shared/Components/{{1}}/{{0}}.cshtml",
$"~/Plugins/misc.pluginName/Views/{{1}}/{{0}}.cshtml",
$"~/Plugins/misc.pluginName/Views/{{0}}.cshtml"
}
.Concat(viewLocations);
}
return viewLocations;
}
public void PopulateValues(ViewLocationExpanderContext context)
{
//no need to add the themeable view locations at all as the administration should not be themeable anyway
if (context.AreaName?.Equals(AreaNames.Admin) ?? false)
return;
var themeContext = (IThemeContext)context.ActionContext.HttpContext.RequestServices.GetService(typeof(IThemeContext));
context.Values[THEME_KEY] = themeContext.WorkingThemeName;
}
}
But i'm unable to override "Topmenu" Component from my plugin.
Thanks.