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