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.

Manish
  • 3,106
  • 7
  • 31
  • 47
  • 1
    Here is the solution but don't want to customize theme https://magento.stackexchange.com/questions/116389/how-to-override-phtml-files-in-magento-2/116463 – Manish Jul 16 '18 at 06:17

2 Answers2

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.

Anshu Mishra
  • 8,950
  • 7
  • 40
  • 88
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.