在Success Page Magento上调用自定义块

时间:2014-09-08 10:54:09

标签: php magento magento-1.7 magento-1.8

我需要在成功页面上调用自定义块

我已按照下面提到的布局尝试了

   <checkout_onepage_success translate="label">
        <reference name="content">
            <block type="checkout/onepage_success" name="checkout.success" template="checkout/success.phtml" >
                <block type="core/template" name="birthday" template="checkout/message/birthday.phtml"/>
            </block>
        </reference>
    </checkout_onepage_success>

成功页面

echo $this->getChildHtml('birthday');

我在页面上两次获得生日区块。

请告诉我们如何在成功页面上调用自定义块。

我不想使用动态块,即

echo $this->getLayout()->createBlock('core/template')
->setTemplate('checkout/message/birthday.phtml')->toHtml(); 

1 个答案:

答案 0 :(得分:4)

由于success.phtml中的这一行,你得到birthday块两次:

 <?php echo $this->getChildHtml() ?>

此行渲染主块的所有子块 如果您只想将其列出一次,请删除

echo $this->getChildHtml('birthday');

无论如何,它将通过getChildHtml方法进行处理。