【发布时间】:2013-03-04 10:00:21
【问题描述】:
你好,
我正在编写一个 Magento 模块。为此,我想在我的模块处理程序中调用一个核心块。我不想修改或扩展核心块。我只想在我的布局处理程序中调用它。有什么建议吗?
我要插入的块位于
adminhtml/sales/order/view/history.php
以下处理程序位于包含上述 Histrory.php 块的 sales.xml 中
<adminhtml_sales_order_addcomment>
<block type="adminhtml/sales_order_view_history" name="order_history" template="sales/order/view/history.phtml" output="toHtml"/>
</adminhtml_sales_order_addcomment>
这是我的 layout.xml
<orderadmin_adminhtml_orderadmin_search>
<update handle="orderadmin_orderadmin_search" />
<reference name="content">
<!-- I want to insert the following block -->
<block type="adminhtml/sales_order_view_history" name="order_history" template="sales/order/view/history.phtml" output="toHtml"/>
</reference>
</orderadmin_adminhtml_orderadmin_search>
但它会导致以下错误。
致命错误:在第 79 行的 \app\code\core\Mage\Adminhtml\Block\Sales\Order\View\History.php 中的非对象上调用成员函数 getId()
【问题讨论】:
-
来电是什么意思?您可以通过
<block type="core/template"... />插入它 -
是的。我想在 layout.xml 中的处理程序中插入核心块
-
是的,就这么做。如果你已经完成了,如果它不起作用,请显示代码
-
-
你能编辑你的问题吗? cmets 中的代码不可读