我在 NopCommerce v4.0 的自定义插件中有以下代码
我正在尝试覆盖 nopcommerce 中 IComponent 的默认 ordertotal 页面,并尝试使用给定代码从我的插件中覆盖
ViewLocationExpander.cs
public class BundledDiscountsViewEngine : IViewLocationExpander
{
public void PopulateValues(ViewLocationExpanderContext context)
{
//nothing to do here.
}
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
{
if (context.AreaName == null && context.ViewName == "Components/OrderTotals/Default")
{
viewLocations = new string[] { $"/Plugins/Demo/Views/Components/OrderTotals/{{0}}.cshtml"
}.Concat(viewLocations);
}
return viewLocations;
}
}
Nopstartup.cs
public class NopStartup : INopStartup
{
public void ConfigureServices(IServiceCollection services, IConfigurationRoot configuration)
{
services.Configure<RazorViewEngineOptions>(options =>
{
options.ViewLocationExpanders.Add(new ViewLocationExpander());
});
}
public void Configure(IApplicationBuilder application)
{
}
public int Order
{
get { return 1001; } //add after nopcommerce is done
}
}
它调用在 ExpandViewLocations.cs 文件中,路径也可以,但它重定向 nopcommerce 的默认页面在 Views/shared/component/OrderTotals/Default.cshtml
我尝试了很多不同的东西,但没有得到任何解决方案,如果有人知道请回复
谢谢伊利亚斯·帕特尔