【问题标题】:Magento Overwrite admin template phtml with one from my moduleMagento 用我的模块中的一个覆盖管理模板 phtml
【发布时间】:2012-07-14 03:01:18
【问题描述】:

我已经习惯了覆盖 magento 的前端布局文件,所以我认为在管理面板中覆盖 phtml 模板会很容易——但在过去的六个小时里我一无所获。到目前为止,我发现的所有教程都集中在创建控制器上,但我只需要覆盖两个 phtml 文件,因为我只想稍微更改订购项目的显示。

具体来说,我想覆盖 default/template/sales/order/view/items.phtml,通常我只需在我自己模块的设计文件夹中匹配该路径即可。

我可以通过我的 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>

如何告诉 Magento 在 design/adminhtml//default/sales/order/view/items.phtml 中使用我的 phtml 文件?

我的 config.xml 中的这些行不应该工作吗?

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

非常感谢任何帮助!我真的希望我只是忽略了一些东西......

【问题讨论】:

    标签: magento php


    【解决方案1】:

    你可以做的是把你的自定义模块放在 Mage_Adminhtml 之前

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

    然后复制到你的order_list.xml

    <adminhtml_sales_order_view> 
        .... 
    </adminhtml_sales_order_view> 
    

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

    在 order_list.xml 中,您现在可以替换块类型和模板文件 (phtml) 位置

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-08
      • 2016-05-18
      相关资源
      最近更新 更多