Home » Magento8 October 2012

Magento: Overriding Template File from Custom Module


I have created a new custom module. Now, I need to edit a default template file.

For example:-

– I have created a new custom module that adds some functionality to Customer Account section on frontend.
– Now, I need to edit the Customer Account Edit template (My Account -> Account Information).
– This template is present in template/customer/form/edit.phtml

I could simply edit this template. But this can result error when the custom module which I have created is disabled.

Therefore, a better solution will be to override the template file. That is to set a new custom template instead of the default one.

Here is how we do it:

This is the default code present in layout/customer.xml (We are not going to edit this)

We just need to set a different template for the block named ‘customer_edit‘ present in the above XML.

Here is our custom module’s XML. This file/code does all the magic for us:

In the XML above, we have set a new template for ‘customer_edit‘ block.

Now, when we go to Customer Account Information section (My Account -> Account Information), our custom module’s template file “mymodule/customer/form/edit.phtml” will be loaded instead of the default template file “customer/form/edit.phtml“.

More about this: Magento Extension Needs to Override a Template

Hope this helps. Thanks.


Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Pingback: Monthly Round Up: ExpressionEngine, WordPress, Magento | @nexcess()

  • What if layout/customer.xml was edited by the user as well? Than how do we override that?

  • Arvind Bhardwaj

    Works perfect.

  • Muhammad Saeed Khan

    what if i want to override the select.phtml file having the layout xml below?


    Thanks in advance :)