spartacus-storefront

SAP Spartacus Create login popup


I need to create registration/login popup.

  1. The header component is on all pages.
  2. I have login button in header.
  3. I have page /login/register with a slot BodyContentSlot-register I don’t know how many components can be added to BodyContentSlot-register, but I need to click on the icon in the header to show the registration form in a modal window without going to the registration page. And show in a modal window all the components of this slot.

Solution

  • To achieve directly what you've described:

    1. In the modal:
    2. you need to make a call using CMS service to get page data (that calls backend for CMS page data) OR get the data if you've loaded it before (as an optimizaiton only)
    3. display the slot's content you want to show, i.e. using cx-page-slot component statically in your modal and passing the position as an input
    4. The tricky part is that this component gets from CmsService the slots of the current page, i.e. cart page (based on routing /cart), but not the page data you've loaded programatically in your modal. So you need to customize CmsService to return you the CMS data for specific slot of given page (register), even if it's not a part of current page data.