I followed Woon Cherk's guide in order to implement the custom view engine: http://www.pronopcommerce.com/3-ways-to-display-views-in-your-nopcommerce-plugins-embedded-resource-theme-override-and-custom-view-engine.
I have stepped through the program during debugging, and I found out that the HeaderLinks method in the CommonController uses my own view engine first as it should, but it only checks the location with the "useCache" parameter set to true. It does not find the view, and continues to search the other default locations with useCache set to first true, and then false. This is where it then returns the view I want to override. If I remove the other views, then it will not return at this point, but instead as a last step, check my own custom view engine path again with the useCache parameter set to false. In this final step, it finds the view I want it to return.
What i'm wondering is why it doesn't check my custom path with useCache set to false until the very end.
My custom view engine:
namespace Nop.Plugin.Misc.MultipleWishlists.Infrastructure
{
public class MultipleWishlistsViewEngine : ThemeableRazorViewEngine
{
public MultipleWishlistsViewEngine()
{
ViewLocationFormats = new[] { "~/Plugins/Misc.MultipleWishlists/Views/{1}/{0}.cshtml" };
PartialViewLocationFormats = new[] { "~/Plugins/Misc.MultipleWishlists/Views/{1}/{0}.cshtml" };
}
}
}
My route provider:
public partial class RouteProvider : IRouteProvider
{
public void RegisterRoutes(RouteCollection routes)
{
ViewEngines.Engines.Insert(0, new MultipleWishlistsViewEngine());
routes.MapRoute("Wishlist",
"wishlists/{wishlistId}",
new { controller = "MultipleWishlists", action = "Wishlist" },
new { wishlistId = @"\d+" },
new[] { "Nop.Plugin.Misc.MultipleWishlists.Controllers" });
routes.MapRoute("Wishlists",
"wishlists",
new { controller = "MultipleWishlists", action = "Wishlists" },
new[] { "Nop.Plugin.Misc.MultipleWishlists.Controllers" });
}
public int Priority
{
get
{
return 1;
}
}
}
Thanks in advance