View Engin Register issue in plugin.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
Anki wrote:
Let me explain you it again,

I have created two plugins. 1. CustomPlugin 2. MyPlugin

I use _productBox.cshtml view page in both plugin.

Now, I have used View Engine in both plugin like:

-->For CustomPlugin
PartialViewLocationFormats =
                new[]
                {      //themes
                      "~/Themes/{2}/Views/{1}/{0}.cshtml",                  
                     "~/Plugins/CustomPlugin/Views/{1}/{0}.cshtml"
                };

--> MyPlugin
PartialViewLocationFormats =
                new[]
                {      //themes
                      "~/Themes/{2}/Views/{1}/{0}.cshtml",                  
                     "~/Plugins/MyPlugin/Views/{1}/{0}.cshtml"
                };

Then I register view engine from Route file like:
ViewEngines.Engines.Insert(0, new CustomPluginViewEngine());
and
ViewEngines.Engines.Insert(0, new MyPluginViewEngine());
respectively.

Now, both of this plugin has _productBox.cshtml page with their own model.

Both plugin's functionality won't work together for this page, if both are installed. If only one is installed then it works fine.

Hope this will helps you to understand my problem clearly.


I think you should return views with path instead of writing view engine in plugin(I have also experienced this ) .Hope It will solve your problem.

Code will like bellow

return View("~/Plugins/MyPlugin/Views/_productBox.cshtml",model);


Or you can write Unique file name.
8 years ago
Anki wrote:
I am getting this error,

The model item passed into the dictionary is of type 'Nop.Plugin.Models.CustomModel', but this dictionary requires a model item of type 'Nop.Plugin.Models.MyPluginModel'.

Because xyz.cshtml page is exist in both plugin. I am trying to run page of Custom plugin but it will find page in MyPlugin first. Hence it throws above error.


Have you tried adding the custom plugin as a reference in myplugin and using the same model - i.e. both plugins use Nop.Plugin.MyPlugin.Model and Nop.Plugin.CustomPlugin has a reference to the dll for MyPlugin and @using in your view and maybe a reference in your Web.config - customplugin will be dependent on myplugin being there else will fail. How complicated is the model?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.