IComponents视图的Nop Commerce自定义视图引擎在nopcommerce 4.0中不起作用

伊利亚斯·帕特尔

我在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文件,路径也可以,但是它在Views / shared / component / OrderTotals / Default.cshtml中重定向了nopcommerce的默认页面。

我已经尝试了许多不同的方法,但是如果有人有任何想法都没有得到任何解决方案,请回复

谢谢Ilyas Patel

萨加尔卡亚斯

我遇到同样的问题,在nop 4.0中,它们采用默认视图路径,您必须像这样声明

  viewLocations = new string[] { $"/Plugins/Demo/Views/{{0}}.cshtml"
                }.Concat(viewLocations);

它会有所帮助

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

自定义视图在Android Lollipop中不起作用

Identity Server 4中的自定义登录视图

自定义视图上的 Onclicklistener 不起作用

搜索在自定义列表视图中不起作用

自定义视图的Android边框底部不起作用

Android自定义视图onDraw不起作用

onitemclicklistener 在自定义列表视图中不起作用

集合视图作为自定义键盘不起作用

iOS 按钮在自定义视图中不起作用

将自定义视图添加到 NavigationBar 中不起作用?

向 Xamarin 的 PDFTron.Android 中不起作用的页面添加自定义视图

UITapGestureRecognizer在自定义类中不起作用(不是视图控制器)

用Xib创建的自定义视图在Interface Builder中不起作用

MBProgressHud视图自定义在Swift 3中不起作用并且不显示吗?

元素视图在CakePHP 4.x中的控制器中不起作用

Angular 4 dblclick事件在移动视图中不起作用

Bootstrap 4 下拉按钮在 mvc 视图中不起作用

为什么两个表格视图单元中的两个集合视图在Swift 4中不起作用?

onResume在视图模型中不起作用

角度4:自定义验证器不起作用

rails4自定义验证不起作用

自定义角度 4 管不起作用

无法添加自定义文本,单选按钮在Rails 4表单中不起作用

自定义 UITableViewCell heightForRowAt 在 Swift 4 中不起作用

我的[(ngModel)]在Ionic 4的自定义组件中不起作用

自定义log4j2附加程序在Java 11中不起作用

离子4自定义离子菜单宽度在iOS中不起作用

如果按钮在自定义视图中使用 let 和 addTarget 初始化,则 UIButton 的操作不起作用,但它在 UIViewController 中起作用

如何将自定义登录失败通知传递给 MVC4 中的视图