0

I just want to override the customer account and login form for adding custom fields and external link. How do I do that using custom module please avoid creating the theme or customize the theme.

1

2 Answers 2

0

Copy login.phtml in your module at the same path app/code/Vendor/Module/view/frontend/templates/form and then create customer_account_login.xml in your custom module at path app/code/Vendor/Module/view/frontend/layout

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="customer_form_login">
            <arguments>
                <argument name="template" xsi:type="string">Vendor_Module::form/login.phtml</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

It didn't try it but I think it should work.

If it works then you can do similar for the create account form as well.

0

If you want to customize .phtml file without customizing theme then you can o it by using the custom module. Let's assume you need to override addtocart.phtml. To do that copy the add to cart file and paste it to your module: app/code/Demo/Mymodule/view/frontend/templates/catalog/product/view.

Once it done then you have to create catalog_product_view.xml in app/code/Demos/Mymodule/view/frontend/layout and add this code in the file:

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <body>
       <referenceBlock name="product.info.addtocart">
           <action method="setTemplate">
               <argument name="template" xsi:type="string">Demo_Mymodule::catalog/product/view/addtocart.phtml</argument>
           </action>
       </referenceBlock>
   </body>
</page>

This is just an example to guide you the process for overriding .phtml files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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