0

I need to customize a customer login form. I need to add social media button in that page as well as register page.

So please give me a solution with customer_account_login.xml and Login.php update and How?

Tried:

<referenceContainer name="content">
    <referenceBlock name="customer_form_login">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Lucent_SocialLogin::form/login.phtml</argument>
        </action>
    </referenceBlock>
</referenceContainer>

i did in custom module Lucent\SocialLogin\view\frontend\layout\customer_account_login.xml but not workin

2
  • You can call your phtml file of social media button in customer_account_create.xml file and customer_account_login.xml file.
    – Raj
    Jul 9 '19 at 10:41
  • 1
    <referenceContainer name="content"> <referenceBlock name="customer_form_login"> <action method="setTemplate"> <argument name="template" xsi:type="string">Lucent_SocialLogin::form/login.phtml</argument> </action> </referenceBlock> </referenceContainer> i did in custom module Lucent\SocialLogin\view\frontend\layout\customer_account_login.xml but not working Jul 9 '19 at 10:43
2

1.Lucent\SocialLogin\view\frontend\layout\customer_account_login.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">
            <referenceBlock name="customer_form_login">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">Lucent_SocialLogin::form/login.phtml</argument>
                </action>
            </referenceBlock>
         </referenceContainer>
    </body>
</page>
  1. Put your content in Lucent\SocialLogin\view\frontend\templates\form\login.phtml

  2. Add remain module require Files and folders.

Thanks

1

your need to changes to

<referenceBlock name="customer_form_login" template="Lucent_SocialLogin::form/login.phtml">

From

<referenceContainer name="content">
    <referenceBlock name="customer_form_login">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Lucent_SocialLogin::form/login.phtml</argument>
        </action>
    </referenceBlock>
</referenceContainer>

You no need to add referenceContainer.

Also make module.xml of Lucent_SocialLogin should dependable of Magento_Customer.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Lucent_SocialLogin" >
        <sequence>
            <module name="Magento_Customer"/> <!-- add dependable -->
        </sequence>
    </module>
</config>
3
  • <referenceContainer name="content"> <referenceBlock name="customer_form_login"> <action method="setTemplate"> <argument name="template" xsi:type="string">Lucent_SocialLogin::form/login.phtml</argument> </action> </referenceBlock> </referenceContainer> working this thanks sir Jul 9 '19 at 10:53
  • You have add some extra code.It do not need.
    – Amit Bera
    Jul 9 '19 at 11:01
  • Ok, sir. Thanks Jul 9 '19 at 11:02
0

Here is two solution you can use , By Overriding controller and plugin (Recommended according to magento guide lines) you can customise the changes you wanna do :

Plugin Implementation :

Add following file : app/code/Verdor/Module/etc/di.xml

<type name="Magento\Customer\Controller\Account\Login">
        <plugin name="change_login" type="Vendor\ModuleName\Plugin\Customer\LoginPlugin" sortOrder="1" disabled="false" />
    </type>
  • Add Plugin file in following location (Vendor\ModuleName\Plugin\Customer\LoginPlugin) and choose your plugin type from following before, after, around .

    namespace Vendor\ModuleName\Plugin\Customer;
    

    use Magento\Customer\Controller\Account\Login;

    class LoginPlugin
    {
    public function afterExecute(Login $subject, $result)
        {
    '''''''''''''
    '''''''''''''
    }
    }
    

Layout Override: Add following file in location :

app\code\Vendor\Module\view\frontend\layout\customer_account_login.xml

Here , YOu can apply  your changes for frontend here, Magento  first execute this file , with  your changes  , (Just simply following fallback  mechanism  here ).

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.