How to create a second register

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

I just want to create a second register view.
I don't want to change the CustomerController or the RegisterModel.
I want to use the existing CustomerController and the existing RegisterModel.
I don't want to change the source code of nopCommerce.

For example normal people use the standard registration of nopCommerce. On the other
hand special people go to the special registration page. (by the click of a button / link)
On the special register page are more fields to fill out and a upload area (for uploading the cv)

What is the easiest way to accomplish this?

Should I create a Misc plugin?
Should I create a Widget plugin?
7 năm cách đây
FlorianNeiss wrote:
Hi,

I just want to create a second register view.
I don't want to change the CustomerController or the RegisterModel.
I want to use the existing CustomerController and the existing RegisterModel.
I don't want to change the source code of nopCommerce.

For example normal people use the standard registration of nopCommerce. On the other
hand special people go to the special registration page. (by the click of a button / link)
On the special register page are more fields to fill out and a upload area (for uploading the cv)

What is the easiest way to accomplish this?

Should I create a Misc plugin?
Should I create a Widget plugin?


Create a Misc plugin
7 năm cách đây
What are the minimal things I have to put in my Misc.Plugin
to create a second register?
7 năm cách đây
FlorianNeiss wrote:
What are the minimal things I have to put in my Misc.Plugin
to create a second register?


Create a route and a get action and a post action with related task.
7 năm cách đây
Ok that means I need:
(NameofPlugin Nop.Plugin.Misc.SpecialRegistry)

- RouteConfig.cs
- SpecialRegistryPlugin.cs
- Views/SpecialRegistry/Register.cshtml
- Controller/SpecialRegistryContoller.cshtml


The web.config
and the description

thats all?
7 năm cách đây
FlorianNeiss wrote:
Ok that means I need:
(NameofPlugin Nop.Plugin.Misc.SpecialRegistry)

- RouteConfig.cs
- SpecialRegistryPlugin.cs
- Views/SpecialRegistry/Register.cshtml
- Controller/SpecialRegistryContoller.cshtml


The web.config
and the description

thats all?


yes. For more information about plugin development visit http://docs.nopcommerce.com/display/nc/How+to+write+a+nopCommerce+plugin.
7 năm cách đây
sohel wrote:


yes. For more information about plugin development visit http://docs.nopcommerce.com/display/nc/How+to+write+a+nopCommerce+plugin.


Hi,

I read the tutorials of the docs.

I've created the most simple plugin for my purpose.


/Controllers/HandelController.cs


using Nop.Web.Models.Customer;
using Nop.Web.Framework.Controllers;
using System.Web.Mvc;

namespace Nop.Plugin.Misc.Handel.Controller {

    internal class HandelController : BasePluginController {

        public ActionResult HandelRegister() {
            var model = new RegisterModel();
            return View("~/Plugins/Misc.Handel/Views/HandelRegister.cshtml", model);
        }
    }
}



/Infrastructure/CustomViewEngine.cs


using Nop.Web.Framework.Themes;

namespace Nop.Plugin.Misc.Handel.Infrastructure {
    public class CustomViewEngine : ThemeableRazorViewEngine {

        public CustomViewEngine() {
            ViewLocationFormats = new[] { "~/Plugins/Misc.Handel/Views/Handel/{0}.cshtml" };
            PartialViewLocationFormats = new[] { "~/Plugins/Misc.Handel/Views/Handel/{0}.cshtml" };
        }
    }
}



HandelPlugin.cs

using Nop.Core.Plugins;

namespace Nop.Plugin.Misc.Handel {
    class HandelPlugin : BasePlugin{

        public override void Install() {
            base.Install();
        }

        public override void Uninstall() {
            base.Uninstall();
        }

    }
}



RouteConfig.cs


using Nop.Plugin.Misc.Handel.Infrastructure;
using Nop.Web.Framework.Mvc.Routes;
using System;
using System.Web.Mvc;
using System.Web.Routing;

namespace Nop.Plugin.Misc.Handel {
    class RouteConfig : IRouteProvider {
        public int Priority {
            get {
                return 0;
            }
        }

        public void RegisterRoutes(RouteCollection routes) {
            routes.MapRoute("HandelRegister",
            "handelregister",
            new { controller = "HandelController", action = "HandelRegister" },
            new[] { "Nop.Plugin.Misc.Handel.Controllers" });

            ViewEngines.Engines.Insert(0, new CustomViewEngine());
        }
    }
}




/Views/Handel/HandelRegister.cshtml

All Code from original register.cshtml
7 năm cách đây
I am using nopCommerce 3.8
But when I try to access my HandelRegister.cshtml i get following error.

http://imgur.com/a/HySQA
7 năm cách đây
FlorianNeiss wrote:
I am using nopCommerce 3.8
But when I try to access my HandelRegister.cshtml i get following error.

http://imgur.com/a/HySQA


write only controller name part like bellow==>

controller = "Handel"



public void RegisterRoutes(RouteCollection routes) {
            routes.MapRoute("HandelRegister",
            "handelregister",
            new { controller = "Handel", action = "HandelRegister" },
            new[] { "Nop.Plugin.Misc.Handel.Controllers" });


And I think don't need "CustomViewEngine"
7 năm cách đây
sohel wrote:
I am using nopCommerce 3.8
But when I try to access my HandelRegister.cshtml i get following error.

http://imgur.com/a/HySQA

write only controller name part like bellow==>

controller = "Handel"



public void RegisterRoutes(RouteCollection routes) {
            routes.MapRoute("HandelRegister",
            "handelregister",
            new { controller = "Handel", action = "HandelRegister" },
            new[] { "Nop.Plugin.Misc.Handel.Controllers" });


And I think don't need "CustomViewEngine"




Thank you for your fast reply.

I am still getting the same error. After changing the bug in route.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.