1

I have created a custom module in Magento 2.1.3 and its layout file is located in

app/code/RP/Testmodule/view/frontend/layout/customer_account_create.xml

but the system loads the layout from

vendor/magento/module-customer/view/frontend/layout/customer_account_create.xml

instead of my custom layout file.

How can I override this vendor layout file with my custom layout file?

My customer_account_create.xml file is

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

but the module does not take this layout.

I have created the resister.phtml and it is located in

app/code/RP/Testmodule/view/frontend/templates/form/register.phtml

My register.phtml file is

<h1>Test</h1> 

My module.xml file is

app/code/RP/Testmodule/etc/module.xml

<?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="RP_Testmodule" setup_version="1.0.0"> <sequence> <module name="Magento_Customer" /> </sequence> </module> </config> 

My di.xml file is

app/code/RP/Testmodule/etc/frontend/di.xml

<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> </config> 

My registration.php file is

app/code/RP/Testmodule/registration.php

<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'RP_Testmodule', __DIR__ ); 

These commands are executed successfully

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento setup:static-content:deploy

php bin/magento cache:clean

php bin/magento cache:flush

But all after that, still it's not working.

Thanks in advance

2 Answers 2

1

Try this:

 <referenceBlock name="customer_form_register"> <action method="setTemplate"> <argument name="template" xsi:type="string">RP_Testmodule::form/register.phtml</argument> </action> </referenceBlock> 

This is working for me.

19
  • Negative, still it's not working. Commented Jun 6, 2018 at 8:08
  • have you flushed cache after update it? Commented Jun 6, 2018 at 8:13
  • Flush, clean, di:compile all tried Commented Jun 6, 2018 at 9:26
  • Is there another modules who overriding same file? Commented Jun 6, 2018 at 9:29
  • No, it's a fresh Magento setup Commented Jun 6, 2018 at 9:31
1

Change to your template with:

<referenceBlock name="customer_form_register" template="Vendor_Modulename::filename.phtml"/> 
1
  • It's also not working. Commented Jun 6, 2018 at 9:30

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.