Registration on HomePage

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi all,
i need to add in the homepage the module for customer registration and customer login.
I don't want the links but show the textbox for user input email and password or all the fields for the custormer registration.

I'm trying to add something like this on HomePage:

@await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.HomepageTop })
@await Component.InvokeAsync("Register")  

But this doesn't work.

Someone can help me with this?
Thanks.
4 years ago
Just wondering are you trying to stop customers browsing the website unless they are logging or registered ?
If so have a look at Configuration -> Access Control List
Clear "Public store. Allow navigation" for all profiles which will achieve this result.

Otherwise can I ask why you want to do this ?

Anyway, What I think you are trying do is use Components ?
Have you made a Component called "Register"
I don’t know much about them but if you look at the other items added to the homepage they are components
For example

        @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.HomepageBeforePoll })
        @await Component.InvokeAsync("HomepagePolls")

HomepagePolls is a component = see nop42\Presentation\Nop.Web\Components\HomepagePolls.cs
I assume this component would then have to call a view which could look like the register / login page then do a bunch of other stuff - seems complicated
And I don’t know if they can be used to do what you want ?
4 years ago
Hi Yidna, thanks for your answer.
Trying to stop custormers browsing the website can be an option, but I’m not asking this now.

I don’t have a Component called “Register”, but I found a view with this name in NopCommerce solution. I’m sorry but I’m not a very expert about MVC model. My need is create an homepage where I can have the login module and register module and other information in the same page. Maybe I need that login and register view become component because I don’t see component of this in the solution.
Do you know if this component exist in the solution or if you know how I can create this component with coding.
Thanks,
Mike
4 years ago
MikLab wrote:
Hi Yidna, thanks for your answer.
Trying to stop custormers browsing the website can be an option, but I’m not asking this now.

I don’t have a Component called “Register”, but I found a view with this name in NopCommerce solution. I’m sorry but I’m not a very expert about MVC model. My need is create an homepage where I can have the login module and register module and other information in the same page. Maybe I need that login and register view become component because I don’t see component of this in the solution.
Do you know if this component exist in the solution or if you know how I can create this component with coding.
Thanks,
Mike


I think you need to create a new register Component for it.

please look Nop.Web > Components > Create new RegisterComponent and you need to create that RegisterComponent view.
RegisterComponent view path is Nop.Web > Views ? Shared > Components > make a new folder of your new RegisterComponent
4 years ago
satyanam wrote:
Hi Yidna, thanks for your answer.
Trying to stop custormers browsing the website can be an option, but I’m not asking this now.

I don’t have a Component called “Register”, but I found a view with this name in NopCommerce solution. I’m sorry but I’m not a very expert about MVC model. My need is create an homepage where I can have the login module and register module and other information in the same page. Maybe I need that login and register view become component because I don’t see component of this in the solution.
Do you know if this component exist in the solution or if you know how I can create this component with coding.
Thanks,
Mike

I think you need to create a new register Component for it.

please look Nop.Web > Components > Create new RegisterComponent and you need to create that RegisterComponent view.
RegisterComponent view path is Nop.Web > Views ? Shared > Components > make a new folder of your new RegisterComponent


Hi, i try with your suggest.
I created the component following your instruction:

In component folder i did this:
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Nop.Web.Factories;
using Nop.Web.Framework.Components;

namespace Nop.Web.Components
{
    /// <summary>
    /// Creata da ML per come componente per la registrazione del cliente da mettere nella homepage
    /// </summary>
    public class HomepageRegister : NopViewComponent
    {
        private readonly ICustomerModelFactory _CustModelFactory;

        public HomepageRegister(ICustomerModelFactory CustModelFactory)
        {
            _CustModelFactory = CustModelFactory;
        }

        public IViewComponentResult Invoke(Models.Customer.RegisterModel _Customermodel)
        {
            var model = _CustModelFactory.PrepareRegisterModel(_Customermodel,false);
            return View(model);
        }
    }
}


In the view component, in the folder Components i create a default.cshtml copying code from Register view;
and in index i add
@await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.HomepageRegister })
        @await Component.InvokeAsync("HomepageRegister")

but nothing is show.

can you help me?
thanks
4 years ago
Component

using Microsoft.AspNetCore.Mvc;
using Nop.Web.Factories;
using Nop.Web.Framework.Components;
using Nop.Web.Models.Customer;

namespace Nop.Web.Components
{
    public class HomepageRegisterViewComponent : NopViewComponent
    {
        private readonly ICustomerModelFactory _customerModelFactory;

        public HomepageRegisterViewComponent(ICustomerModelFactory customerModelFactory)
        {
            _customerModelFactory = customerModelFactory;
        }

        public IViewComponentResult Invoke()
        {
            var model = new RegisterModel();
            model = _customerModelFactory.PrepareRegisterModel(model, false, setDefaultValues: true);

            return View(model);
        }
    }
}

View
You can copy/paste from the Register page and remove line Layout = "_ColumnsOne";
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.