How to override the admin template file in magento?
I Recommend you that create a new template and add new design in your module with the layout update for the adminhtml section. For example:
In your config.xml of your custom extension you can update the layout of adminhtml with:
<adminhtml>
<layout>
<updates>
<adminhtml>
<file>yourcustomlayout.xml</file>
</adminhtml>
</updates>
</layout>
</adminhtml>
Ok, then since this layout you can write the next code to add a css for example:
<layout>
<default>
<reference name="head">
<action method="addCss">
<name>aw_all/css/window.css</name>
</action>
</reference>
</default>
</layout>
In your case you need add you custom template for your block
<layout>
<handle>
<reference name="content">
<block type="smspremium/adminhtml_smspremium" name="smspremium">
<action method="setTemplate">
<template>customtemplate.phtml</template>
</action>
</block>
</reference>
</handle>
</layout>
If you want to discart all the block and replace with your block you can made unsetChild
<layout>
<handle>
<reference name="content">
<action method="unsetChild"><name>your.last.block</name></action>
<block type="smspremium/adminhtml_smspremium" name="smspremium">
<action method="setTemplate">
<template>customtemplate.phtml</template>
</action>
</block>
</reference>
</handle>
</layout>
This work same the frontend layout, only with the diference of the directory since you store your files. For Templates:
app/design/adminhtml/default/default/templates
For layout:
app/design/adminhtml/default/default/layout
Hope help you
Tejas Shah
Working as Magento Team Lead, where we develop beautiful Magento themes and Magento extensions.
Updated on June 04, 2022Comments
-
Tejas Shah almost 2 years
I need to override the "adminhtml/sales/order/create/items/grid.phtml" file to display some custom text under each item while creating new order from admin. I want this to be done through custom module. Anyone can suggest how to override the admin template files? Any help is really appreciated
-
Tejas Shah about 12 yearsThanks! It works for me. But It needs page refresh to display the custom text any idea about this? I want the it without refresh
-
AndyG over 10 yearsInstead of linking to any site on the web, post the appropriate contents in your answer. You can optionally provide a link for where you got the info afterwards.
-
ermannob almost 10 yearsHi, I'm not sure about your config.xml. Is that correct? Shouldn't the inner <adminhtml> be replaced with <your_module_name>? Thanks.