How to override the admin template file in magento?

后端 未结 4 472
萌比男神i
萌比男神i 2021-01-15 13:27

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

相关标签:
4条回答
  • 2021-01-15 14:05

    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

    0 讨论(0)
  • 2021-01-15 14:09

    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

    0 讨论(0)
  • 2021-01-15 14:15

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

    0 讨论(0)
  • 2021-01-15 14:28

    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.

    0 讨论(0)
提交回复
热议问题