Magento 将新块插入product.info';行不通

Magento 将新块插入product.info';行不通,magento,block,Magento,Block,我创建了两个新块,应该在该块之前和之后输出: <block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"/> 为此,我创建了一个新模块,用于更新布局。引用的XML文件中包含以下内容: <catalog_product_view> <reference name="

我创建了两个新块,应该在该块之前和之后输出:

<block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"/>

为此,我创建了一个新模块,用于更新布局。引用的XML文件中包含以下内容:

<catalog_product_view>
  <reference name="product.info">
    <block type="disablecartonlogout/output" name="disablecartonlogout.outputbefore" as="whatever" before="product.info.addtocart" template="disablecartonlogout/product-options-bottom-before.phtml" />
    <block type="disablecartonlogout/output" name="disablecartonlogout.outputafter" as="whatever" after="product.info.addtocart" template="disablecartonlogout/product-options-bottom-after.phtml" />
  </reference>
</catalog_product_view>

我没有输出。 如果我将引用更改为“内容”,将输出块,但位置错误


你能告诉我,我做错了什么吗?

你需要在你想要的地方明确地调用
product.info
块模板(应该是
catalog/product/view.phtml
)中的块


您想要使用的方法仅适用于某些特定的块(通常,
core/text\u list
core/template
执行空的
getChildHtml()
调用,而
product.info
的情况除外)

您需要在
product.info
块模板中显式调用您的块(应该是
catalog/product/view.phtml
),在您想要的地方

您想要使用的方法仅适用于某些特定块(通常,
core/text\u list
core/template
执行空的
getChildHtml()
调用,而
product.info
的情况除外)

试试这个,因为它可能对你有帮助。我试过这样的东西


试试这个,因为它可能会对你有所帮助。我试过类似这样的方法。你是在模板中调用块吗?我不明白你的问题。我想像问题中写的那样调用我的块。你是在模板中调用块吗?我不明白你的问题。我想像问题中写的那样调用我的块。是的,谢谢,我是curre在这个view.phtml中,我明白你的意思。我真的不想触及核心文件,那么是否有可能替换整个“product.info.addtocart”使用my block进行块,它再次包含原始块?这样我就可以把一些东西包起来。要将原始HTML包起来,您可以在
Mage\u core\u block\u abstract\u To\u HTML\u after
事件上使用观察者,该事件在
Mage\u core\u block\u abstract::toHtml()中调度
。只要给定的块命名为
product.info.addtocart
(如果需要,当当前操作与您想要的相对应时),然后可以使用
transport
对象更新HTML结果。Uff,谢谢。听起来有点太复杂,但可能这是唯一的方法。好的,我复制了view.phtml和wrapper.phtml和wrapper/bottom.phtml,并添加了自己的getChildHtml()调用-但是现在整个模板都被复制了,如果magento更新更改了某些内容,这些更改就会被覆盖。是的,谢谢,我现在在这个视图中。phtml,我明白你的意思。我真的不想接触核心文件,所以是否有可能替换整个“product.info.addtocart”使用my block进行块,它再次包含原始块?这样我就可以把一些东西包起来。要将原始HTML包起来,您可以在
Mage\u core\u block\u abstract\u To\u HTML\u after
事件上使用观察者,该事件在
Mage\u core\u block\u abstract::toHtml()中调度
。只要给定的块命名为
product.info.addtocart
(如果需要,当当前操作与您想要的相对应时),然后可以使用
transport
对象更新HTML结果。Uff,谢谢。听起来有点太复杂,但可能这是唯一的方法。好的,我复制了view.phtml和wrapper.phtml和wrapper/bottom.phtml,并添加了自己的getChildHtml()调用-但是现在整个模板都被复制了,如果magento更新在那里更改了某些内容,这些更改就会被覆盖。
<catalog_product_view>
    <reference name="product.info.addtocart">
        <block type="disablecartonlogout/output" name="disablecartonlogout.outputbefore" as="whatever1" before="-" template="disablecartonlogout/product-options-bottom-before.phtml" />
        <block type="disablecartonlogout/output" name="disablecartonlogout.outputafter" as="whatever2" after="-" template="disablecartonlogout/product-options-bottom-after.phtml" />
    </reference>
</catalog_product_view>
$this->getChildHtml('whatever1', true, true);
$this->getChildHtml('whatever2', true, true);