Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Magento:调用模块内的核心块_Php_Magento - Fatal编程技术网

Php Magento:调用模块内的核心块

Php Magento:调用模块内的核心块,php,magento,Php,Magento,你好 我正在写一个Magento模块。为此,我想在模块的处理程序中调用一个核心块。我不想修改或扩展核心块。我只想在布局处理程序中调用它。有什么建议吗 我要插入的块位于中 adminhtml/sales/order/view/history.php 以下处理程序位于sales.xml中,其中包含上述histroy.php块 <adminhtml_sales_order_addcomment> <block type="adminhtml/sales_order


你好 我正在写一个Magento模块。为此,我想在模块的处理程序中调用一个核心块。我不想修改或扩展核心块。我只想在布局处理程序中调用它。有什么建议吗

我要插入的块位于中

adminhtml/sales/order/view/history.php
以下处理程序位于sales.xml中,其中包含上述histroy.php块

 <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()


您必须在代码中这样做:

<!-- this is my handler -->
<orderadmin_adminhtml_orderadmin_search>
        <update handle="orderadmin_orderadmin_search" />
        <reference name="content">
            <block type="orderadmin/adminhtml_search" name="search_order" />
            <!-- I want to call the core block here -->

从核心布局中选取所需的块,并按原样粘贴到此处 是的,它将被渲染


问题与xml布局无关,xml布局事实上是正确的,可以按原样工作

问题是因为此块希望注册表中有一个订单,以便它能够获取历史记录

在呈现历史记录块之前,应在控制器或模块块内的注册表中设置顺序(您希望用于查看历史记录的顺序)

// load your order here..
Mage::register('sales_order', $order);

你说的电话是什么意思?您可以通过
是插入它。我想在layout.xmlYes的处理程序中插入核心块,就这样做吧。如果你已经做了,显示代码如果它不起作用你能编辑你的问题吗?注释中的代码无法访问感谢您的解决方案。我已经试过了。但它不起作用。请提供任何建议?您好,我想在控制器的操作中插入adminhtml/default/default/layout/sales.xml中的以下块您是否编写了$this->loadLayout()->renderLaout();。。。?有时,直接
引用“内容”
虽然应该执行,但并不执行所有子项。你可以试着将它们封装在包装器中。这不是推荐的解决方案,但你可以试试
和您的phtml尝试使用
echo$this->getChildHtml('order\u history')
非常感谢。在寄存器中保存订单id后,错误被修复。您好,我在处理程序中添加了块。但当我添加评论并提交时,它不会显示在评论列表中。请帮忙?
// load your order here..
Mage::register('sales_order', $order);