Guide to Overriding NopCommerce Admin Views and Partial Views

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 năm cách đây
Hey All,

I had a couple scenarios where I wanted to override some Nop admins views and was experimenting with the best way to do it.  I also saw some questions out there on various forums asking how to do this.  I thought I'd compile my findings into a blog post that walks you through how to override Admin Views and Partial Views with ease.

Check Out the Post Here

Please let me know what you think!
8 năm cách đây
Hi,

I am trying to override an admin partial view(Nop.Web\Administration\Views\Order\_OrderDetails.Shipping.cshtml used in the Nop.Web\Administration\Views\Order\Edit.cshtml) in a Shipping Computation method plugin.
I followed the guidelines in your blog post but couldn't quite manage to accomplish the task.

I created  a CustomViewEngine which inherits from RazorViewEngine, added the partial view search locations.
Next I inserted the CustomViewEngine before the other View engines in my RouteCoinfig class.
Since I am overriding partial view, I don't need a controller and route to it.
So finally I added my partial view to the search location in my plugin.

Unfortunately the effect was that Nop was still using its own admin views. Only when I rename the original partial view, Nop loads the one from the plugin. When I rename it as well, I can see the search locations in the browser with my plugin's location at the front:

The partial view '_OrderDetails.Shipping' was not found or no view engine supports the searched locations. The following locations were searched:
~/Plugins/Shipping.Rapido/Views/_OrderDetails.Shipping.cshtml
~/Administration/Views/Shared/_OrderDetails.Shipping.cshtml
~/Administration/Views/Order/_OrderDetails.Shipping.cshtml
...

It looks as if I am missing something.
Maybe after all I should override the parent admin view as well, add an action for it and a controller route.
8 năm cách đây
[email protected] wrote:
Hi,

I am trying to override an admin partial view(Nop.Web\Administration\Views\Order\_OrderDetails.Shipping.cshtml used in the Nop.Web\Administration\Views\Order\Edit.cshtml) in a Shipping Computation method plugin.
I followed the guidelines in your blog post but couldn't quite manage to accomplish the task.

I created  a CustomViewEngine which inherits from RazorViewEngine, added the partial view search locations.
Next I inserted the CustomViewEngine before the other View engines in my RouteCoinfig class.
Since I am overriding partial view, I don't need a controller and route to it.
So finally I added my partial view to the search location in my plugin.

Unfortunately the effect was that Nop was still using its own admin views. Only when I rename the original partial view, Nop loads the one from the plugin. When I rename it as well, I can see the search locations in the browser with my plugin's location at the front:

The partial view '_OrderDetails.Shipping' was not found or no view engine supports the searched locations. The following locations were searched:
~/Plugins/Shipping.Rapido/Views/_OrderDetails.Shipping.cshtml
~/Administration/Views/Shared/_OrderDetails.Shipping.cshtml
~/Administration/Views/Order/_OrderDetails.Shipping.cshtml
...

It looks as if I am missing something.
Maybe after all I should override the parent admin view as well, add an action for it and a controller route.


Check the property of the file. Make copy always for Copy to output directories.
8 năm cách đây
No this is not the problem, the overridden partial view is copied to the output directory as expected,  but the view engine uses it  only if the original one is missing.
8 năm cách đây
Then I think  you can use this code in action controller to get your view

return PartialView("~/Plugins/Shipping.Rapido/Views/_OrderDetails.Shipping.cshtml", Model);
8 năm cách đây
anik1991 wrote:
Then I think  you can use this code in action controller to get your view

return PartialView("~/Plugins/Shipping.Rapido/Views/_OrderDetails.Shipping.cshtml", Model);


No it is not working.I set copy always and the path is exactly as you told but it shows error and the message is
"The partial view  was not found or no view engine supports the searched locations."

Can anybody share a perfect link or solution.
8 năm cách đây
Can you give me the screen shot of your code and  folder structure of your project and also screenshot of debuging error? So that I can test.
7 năm cách đây
Hello,
Does anyone have a solution for this? I also got stuck in same scenario.
7 năm cách đây
partial view cant loaded on nopcommerce 3.8 on plugin side.I write this on controller side.
return PartialView("~/Plugins/Twigoh.Sellers/Views/Dashboard/vendorProfile.cshtml", model);
and view side @Html.Partial("vendorProfile"); Action name and view almost same.
7 năm cách đây
arw002 wrote:
Hey All,

I had a couple scenarios where I wanted to override some Nop admins views and was experimenting with the best way to do it.  I also saw some questions out there on various forums asking how to do this.  I thought I'd compile my findings into a blog post that walks you through how to override Admin Views and Partial Views with ease.

Check Out the Post Here

Please let me know what you think!


Hi I followed all the steps from http://alexwolfthoughts.com/overriding-nopcommerce-admin-views-and-partial-views

But the view is not overridden.
Using nopCommerce 3.80 currently.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.