Magento – How to override the admin template file in magento

magentooverriding

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

Best Answer

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

Related Topic