简体   繁体   English

Magento用我模块中的一个覆盖管理模板phtml

[英]Magento Overwrite admin template phtml with one from my module

I've gotten quite used to overwriting magento's frontend layout files, so I thought it would be easy to overwrite a phtml template in the admin panel - but I've gotten nowhere in the last six hours. 我已经习惯了覆盖magento的前端布局文件,因此我认为在管理面板中覆盖phtml模板会很容易-但最近六个小时我仍然无所获。 All tutorials I've found so far are concentrating on creating a controller, but I only need to overwrite two phtml files since I only want to change the dispaly of the ordered items a little. 到目前为止,我发现的所有教程都专注于创建控制器,但是我只需要覆盖两个phtml文件,因为我只想稍微更改订购项的显示。

Specifically I want to overwrite the default/template/sales/order/view/items.phtml, normally i'd just match that path in my design folder of my own module and call it a day. 具体来说,我想覆盖default / template / sales / order / view / items.phtml,通常我会将该路径与自己模块的设计文件夹中的路径匹配,并称之为一天。

I can overwrite the block php file in Mage/Adminhtml/Sales/Order/View/Items.php through my config.xml: 我可以通过config.xml覆盖Mage / Adminhtml / Sales / Order / View / Items.php中的阻止php文件:

<config>
...
   <global>
   ...
     <blocks>
     ...
        <adminhtml>
            <rewrite>
                <sales_order_view_items>MyCompany_MyModule_Block_Adminhtml_Sales_Order_View_Items</sales_order_view_items>
            </rewrite>
        </adminhtml>
      </blocks>
    ...
    </global>
 ...
 </config>

How can I tell Magento to use my phtml file in design/adminhtml//default/sales/order/view/items.phtml ? 如何告诉Magento在design / adminhtml // default / sales / order / view / items.phtml中使用我的phtml文件?

Shouldn't these lines in my config.xml work? 我的config.xml中的这些行不起作用吗?

<config>
...
<adminhtml>
    <layout>
        <updates>
            <my_module>
                <file>order_list.xml</file>
            </my_module>
        </updates>
    </layout>
</adminhtml>
...
</config>

Any help is really appreciated! 任何帮助都非常感谢! I really hope I've just overlooked something... 我真的希望我只是忽略了一些东西...

What you could do is put your custom module before Mage_Adminhtml 您可以做的是将自定义模块放在Mage_Adminhtml之前

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <My_Module before="Mage_Adminhtml">My_Module_Adminhtml</My_Module>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

Then copy to your order_list.xml 然后复制到您的order_list.xml

<adminhtml_sales_order_view> 
    .... 
</adminhtml_sales_order_view> 

from /app/design/adminhtml/default/default/layout/sales.xml 来自/app/design/adminhtml/default/default/layout/sales.xml

In order_list.xml you could now replace the block type and template file (phtml) location 现在,您可以在order_list.xml中替换块类型和模板文件(phtml)的位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM