How to Override View in Nopcommerce?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
10 years ago
Hey guys,

I am creating one plug-in using data-access and widget in nopcommerce.

In that i have created my widget that i want to display on ProductDetails Page by replacing (overriding) Product-Image & its thumbs.

But i don't know how to override views and even don't know is it possible in nopcommerce or not.

Please can anyone help me.

If possible please provide an example as well, so that i can understand actually how it overrides in nopcommerce.

Thanks in anticipation.
10 years ago
You can override Views by placing your copy in the \Themes\theme_you_are_using\Views folder.
Use same name and same folder structure.  Only copy/modify the specific .cshtml files you need.

read this for more info https://www.nopcommerce.com/docs/72/designers-guide.aspx
10 years ago
abhay1087 wrote:
Hey guys,

I am creating one plug-in using data-access and widget in nopcommerce.

In that i have created my widget that i want to display on ProductDetails Page by replacing (overriding) Product-Image & its thumbs.

But i don't know how to override views and even don't know is it possible in nopcommerce or not.

Please can anyone help me.

If possible please provide an example as well, so that i can understand actually how it overrides in nopcommerce.

Thanks in anticipation.


You can also try this article I've written: http://www.pronopcommerce.com/3-ways-to-display-views-in-your-nopcommerce-plugins-embedded-resource-theme-override-and-custom-view-engine
10 years ago
I have already visited those links and could not find any solution.

Actually i have created one partial view that i want to replace with existing partial view in Product Details Page.

My Route is as follows:

using System.Web.Mvc;
using System.Web.Routing;
using Nop.Web.Framework.Mvc.Routes;

namespace Nop.Plugin.Indies.ProductVideo
{
    public partial class RouteProvider : IRouteProvider
    {
        public void RegisterRoutes(RouteCollection routes)
        {
         //   System.Web.Mvc.ViewEngines.Engines.Add(new MyCustomViewEngine());
            
            routes.MapRoute("Plugin.Indies.ProductVideo.Configure",
                 "Plugins/IndiesProductVideo/Configure",
                 new { controller = "ProductVideo", action = "Configure" },
                 new[] { "Nop.Plugin.Indies.ProductVideo.Controllers" }
            );

            routes.MapRoute("Plugin.Indies.ProductVideo.VideoList",
                "Plugins/IndiesProductVideo/VideoList",
                new { controller = "ProductVideo", action = "VideoList" },
                new[] { "Nop.Plugin.Indies.ProductVideo.Controllers" }
           );

            routes.MapRoute("Plugin.Indies.ProductVideo._ProductDetailsPictures",
                "Plugins/IndiesProductVideo/_ProductDetailsPictures",
                new { controller = "ProductVideo", action = "_ProductDetailsPictures" },
                new[] { "Nop.Plugin.Indies.ProductVideo.Controllers" }
           );

        }
        public int Priority
        {
            get
            {
                return 100;
            }
        }
    }
}

MY Controller Code:

        [ChildActionOnly]
        public ActionResult _ProductDetailsPictures()
        {
            var model = this._productVideoService.GetVideoListByProductid(7);
            return PartialView("Nop.Plugin.Indies.ProductVideo.Views.ProductVideo._ProductDetailsPictures", model);
            //return View(model);
        }

In Above Route i want third route to be replaced with @Html.Partial("_ProductDetailsPictures", Model) of ProductTemplate.Simple.cshtml page in ProductDetails page but don't know where i am doing mistake.

Can anyone help me to find solution and make it possible for me.
9 years ago
wooncherk wrote:
Hey guys,

I am creating one plug-in using data-access and widget in nopcommerce.

In that i have created my widget that i want to display on ProductDetails Page by replacing (overriding) Product-Image & its thumbs.

But i don't know how to override views and even don't know is it possible in nopcommerce or not.

Please can anyone help me.

If possible please provide an example as well, so that i can understand actually how it overrides in nopcommerce.

Thanks in anticipation.

You can also try this article I've written: http://www.pronopcommerce.com/3-ways-to-display-views-in-your-nopcommerce-plugins-embedded-resource-theme-override-and-custom-view-engine



Your Custom View Engine method is excellent in preparing our Views to be overriden in the future but not so much when we wanted to override an existing core View.

I have followed your instructions to the letter but my custom View is never used. So I deleted/renamed the original existing core View and refreshed the page. Now my custom View is being rendered. It got me thinking that perhaps this is an issue with precedence/priority. So in order to test my theory, I went ahead and deleted/renamed my custom View as well. This will definitely throw an error with the system saying it couldn't find any associated Views. My only interest is the priority list. You can refer to the screenshot here http://i.imgur.com/AJgSrnt.jpg

This confirms that it is indeed the problem with precedence. Is there any way to go about it giving custom View a higher precedence?
9 years ago
I have created one widget , but after installation user has to write one line of code in product detail view. I want to override default product details view from view of my plug-in. so user dont need write any code after my plugin is ready.


Is this possible?


thanks ,
9 years ago
I have got the Solutions.
8 years ago
hello guys i am facing some issue in plugin development. i make product plugin for little bit modification and little tweaks. i face a issue when i hit plugin controller and they hit my Nop.Admin Product Controller. whats i m doing wrong in plugin.
thanks
8 years ago
hassanabbas wrote:
hello guys i am facing some issue in plugin development. i make product plugin for little bit modification and little tweaks. i face a issue when i hit plugin controller and they hit my Nop.Admin Product Controller. whats i m doing wrong in plugin.
thanks


Check you route ... Maybe you set area=admin. or somehow you  have put a call to this controller.  We don't see your code... go through your code and also views
6 years ago
Hello guys,

I have one quick question related to the views overriding. I didn't want to open an entire new theme because I thought that my question is acceptable for this theme.

Question: I have a plugin. In this plugin I'm overriding view from Nop.Admin\Views\Customer\_CreateOrUpdate.cshtml and now I need to override view from Nop.Admin\Views\EmailAccount\_CreateOrUpdate.cshtml. How to override these two views in my plugin and how to make the system knows when what view to search and where to find it, given that these two views are with the same name?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.