Tejas Shah
Tejas Shah

Reputation: 563

How to override the admin template file in magento?

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

Upvotes: 2

Views: 11722

Answers (4)

batMask
batMask

Reputation: 744

First of all I'm not believe this is the correct way of overriding adminhtml templates. But I try this approach and it works, So just wanna share.

Add this to your custom Module config.xml

<stores>
        <admin>
            <design>
                <theme>
                    <default>default</default>
                    <template>mycustom</template>
                </theme>
            </design>
        </admin>
</stores>

Now You can just override by copying templates from default to mycustom app\design\adminhtml\default\default\template\sales\order\view\history.phtml app\design\adminhtml\default\mycustom\template\sales\order\view\history.phtml

Upvotes: 0

davidselo
davidselo

Reputation: 1325

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

Upvotes: 4

Pawan
Pawan

Reputation: 1

You can find the detailed instructions for overriding Magento admin files here http://www.techawaken.com/creating-a-new-magento-admin-theme/

Upvotes: -1

vsushkov
vsushkov

Reputation: 2435

Basically, you have to declare a new layout file for your module for adminhtml area, than set a new template path using setTemplate method and reference[name] node.

Upvotes: 0

Related Questions