In my case i want to override
\Administration\Views\Product\_CreateOrUpdate.SpecificationAttributes.cshtml
Step 1. Register in MyModule my view engine
public class RouteProvider : IRouteProvider
{
public void RegisterRoutes(RouteCollection routes)
{
ViewEngines.Engines.Insert(0, new MyViewEngine());
}
}
Step 2. MyViewEngine
public class MyViewEngine : RazorViewEngine
{
public MyViewEngine()
{
ViewLocationFormats = new string[]
{
"~/Plugins/<my module>/Views/{1}/{0}.cshtml",
"~/Plugins/<my module>/Views/Shared/{0}.cshtml"
};
PartialViewLocationFormats = new string[]
{
"~/Plugins/<my module>/Views/{1}/{0}.cshtml",
"~/Plugins/<my module>/Views/Shared/{0}.cshtml"
};
AreaPartialViewLocationFormats = PartialViewLocationFormats;
AreaViewLocationFormats = ViewLocationFormats;
}
}
Step 3. Result
I was not able to override _CreateOrUpdate.SpecificationAttributes.cshtml with my customized view inside mymodule.
it is keep using the default
\Administration\Views\Product\_CreateOrUpdate.SpecificationAttributes.cshtml
Is it because
1. The view is being called inside another view?
product\_CreateOrUpdate.cshtml
@helper TabSpecificationAttributes()
{
@Html.Partial("_CreateOrUpdate.SpecificationAttributes", Model)
}
2. Because "Nop.Web.Framework\Themes\ThemeableVirtualPathProviderViewEngine.cs"
function "GetPath"
has this hack line 138 ?
//little hack to get nop's admin area to be in /Administration/ instead of /Nop/Admin/ or Areas/Admin/
if (!string.IsNullOrEmpty(areaName) && areaName.Equals("admin", StringComparison.InvariantCultureIgnoreCase))
{
var newLocations = areaLocations.ToList();
newLocations.Insert(0, "~/Administration/Views/{1}/{0}.cshtml");
newLocations.Insert(0, "~/Administration/Views/Shared/{0}.cshtml");
areaLocations = newLocations.ToArray();
}
Is there a workaround?