1

I have created my custom module for specific customer group. so, admin will send link to customer to download some matter after login.

The login URL and login screen will be different for normal customer and specific customer group.

I have created the Module, but now how I can call the customer lgoin form on my custom URL action?

Could anyone help me out this issue?

1

You need to create layout handle to call login form in your custom module url

For ex. your routes.xml like

app/code/Vendor/Module/etc/frontend/routes.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route frontName="test" id="test">
            <module name="Vendor_Module"/>
        </route>
    </router>
</config>

Your Controller like

app/code/Vendor/Module/Controller/Index/Index.php

<?php

namespace Vendor\Module\Controller\Index;

class Index extends \Magento\Framework\App\Action\Action
{

    protected $resultPageFactory;

    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
    ) {
        $this->resultPageFactory = $resultPageFactory;
        parent::__construct($context);
    }

    public function execute()
    {
        return $this->resultPageFactory->create();
    }
}

Then create test_index_index.xml to handle test url and call login from

app/code/Vendor/Module/view/frontend/layout/test_index_index.xml

<?xml version="1.0" ?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
           <container name="customer.login.container" label="Customer Login Container" htmlTag="div" htmlClass="login-container">
                <block class="Magento\Customer\Block\Form\Login" name="customer_form_login" template="form/login.phtml">
                    <container name="form.additional.info" as="form_additional_info"/>
                </block>
                <block class="Magento\Customer\Block\Form\Login\Info" name="customer.new" template="newcustomer.phtml"/>
            </container>
        </referenceContainer>
    </body>
</page>
  • Thanks it's working fine as expected. But my login page is already override by the Magepalaza Social extension. So how I can override the login page on my custom login page? Please help. – mageDev0688 Jun 14 '17 at 9:04
  • 1
    yes you can override after override by megaplaza social extension. i have done it . – Sarvesh Tiwari Jun 19 '17 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.