且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

覆盖Magento Adminhtml模板文件

更新时间:2023-11-30 10:31:10

如果其他模块在adminhtml_block_html_before事件上使用观察者,重写他们的观察者模型,使它做你想要的?

在同一时间,你也可以在同一事件上添加你自己的观察者,这将做同样的事情,但只有当其他模块未启用(例如,通过检查 Mage :: helper('core') - > isModuleEnabled()),以便它可以在所有情况下工作。 / p>

I'm attempting to override a particular block on a page, in this case it's the Sales_Order_View_History template. The problem I'm seeing is that this block is already being overridden.

The custom module that is overriding this block is using an observer that basically does: when History.php is to be loaded, load Historytwo.php instead. History.php is also being used on two separate pages in the back end. I must only override it on one page. This has gotten me absolutely lost. I do believe that the module I'm wanting to override the template of is only overriding the one I'd like to override.

What I have seen as the generally accepted format for overriding blocks is:

<adminhtml>
    <rewrite>
       <sales_order_view_companyhistory>
       Namespace_Package_Blocks_Adminhtml_Sales_Order_View_Companyhistory_Content</

The above code is giving me a broken layout that is stopping the rendering of most of the blocks/templates.

If the other module uses an observer on the "adminhtml_block_html_before" event, have you tried to rewrite their observer model to make it do what you want ?
And in the same time, you could also add your own observer on the same event, that would do the same thing, but only when the other module is not enabled (eg, by checking with Mage::helper('core')->isModuleEnabled()), so that it would work in all cases.